Mercurial > repos > IBBoard
annotate Limits/NumericSizeConstrainedLimit.cs @ 107:0f88d32b22cc
* Swap to built-in .Net methods (listed on http://www.ironshay.com/post/Use-NET-Built-in-Methods-to-Save-Time-and-Headaches.aspx)
no-open-ticket
author | IBBoard <dev@ibboard.co.uk> |
---|---|
date | Sat, 13 Aug 2011 10:42:57 +0000 |
parents | c6ed77f263a6 |
children |
rev | line source |
---|---|
49
a177a3750acd
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
1 // This file (NumericSizeConstrainedLimit.cs) is a part of the IBBoard project and is copyright 2009 IBBoard |
47
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
2 // |
49
a177a3750acd
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
3 // The file and the library/program it is in are licensed under the GNU LGPL license, either version 3 of the License or (at your option) any later version. Please see COPYING.LGPL for more information and the full license. |
47
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
4 |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
5 using System; |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
6 |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
7 namespace IBBoard.Limits |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
8 { |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
9 /// <summary> |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
10 /// A limit of a specified number, or the number it is limited against, whichever is smaller. |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
11 /// </summary> |
57 | 12 public class NumericSizeConstrainedLimit : AbstractLimit, INumericLimit |
59 | 13 { |
14 /// <summary> | |
15 /// Default constructor that will always return the constrained number, no matter what size it is | |
16 /// </summary> | |
17 public NumericSizeConstrainedLimit() : this(int.MaxValue) | |
18 { | |
19 } | |
20 | |
49
a177a3750acd
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
21 public NumericSizeConstrainedLimit (int numericLimit) : base(numericLimit) |
47
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
22 { |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
23 } |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
24 |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
25 /// <summary> |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
26 /// Gets the limited number, based on the limit that this <code>Limit</code> represents and the maximum size. |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
27 /// </summary> |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
28 /// <param name="size"> |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
29 /// The maximum size |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
30 /// </param> |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
31 /// <returns> |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
32 /// <code>size</code> or the numeric limit this object was created with, whichever is smaller. |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
33 /// </returns> |
50
e98708559618
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
49
diff
changeset
|
34 public override int GetLimit(int size) |
47
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
35 { |
49
a177a3750acd
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
47
diff
changeset
|
36 return (int)Math.Min(size, Limit); |
47
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
37 } |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
38 } |
966ba575d4e6
Re #24: Add "limit" objects that can be used for numeric limits
IBBoard <dev@ibboard.co.uk>
parents:
diff
changeset
|
39 } |