Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
MinLengthAttribute.cs
Go to the documentation of this file.
3
5
6[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]
8{
9 public int Length { get; }
10
11 [RequiresUnreferencedCode("Uses reflection to get the 'Count' property on types that don't implement ICollection. This 'Count' property may be trimmed. Ensure it is preserved.")]
13 : base(System.SR.MinLengthAttribute_ValidationError)
14 {
15 Length = length;
16 }
17
18 [UnconditionalSuppressMessage("ReflectionAnalysis", "IL2026:RequiresUnreferencedCode", Justification = "The ctor is marked with RequiresUnreferencedCode.")]
19 public override bool IsValid(object? value)
20 {
22 if (value == null)
23 {
24 return true;
25 }
26 int num;
27 if (value is string text)
28 {
29 num = text.Length;
30 }
31 else
32 {
34 {
36 }
37 num = count;
38 }
39 return num >= Length;
40 }
41
42 public override string FormatErrorMessage(string name)
43 {
44 return string.Format(CultureInfo.CurrentCulture, base.ErrorMessageString, name, Length);
45 }
46
47 private void EnsureLegalLengths()
48 {
49 if (Length < 0)
50 {
52 }
53 }
54}
static bool TryGetCount(object value, out int count)
static CultureInfo CurrentCulture
static string Format(string resourceFormat, object p1)
Definition SR.cs:118
static string LengthAttribute_InvalidValueType
Definition SR.cs:68
static string MinLengthAttribute_InvalidMinLength
Definition SR.cs:64
Definition SR.cs:7