Terraria
v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CreditCardAttribute.cs
Go to the documentation of this file.
1
namespace
System.ComponentModel.DataAnnotations
;
2
3
[AttributeUsage(
AttributeTargets
.Property |
AttributeTargets
.Field |
AttributeTargets
.Parameter, AllowMultiple =
false
)]
4
public
sealed
class
CreditCardAttribute
:
DataTypeAttribute
5
{
6
public
CreditCardAttribute
()
7
: base(
DataType
.
CreditCard
)
8
{
9
base.DefaultErrorMessage =
System
.
SR
.
CreditCardAttribute_Invalid
;
10
}
11
12
public
override
bool
IsValid
(
object
?
value
)
13
{
14
if
(
value
==
null
)
15
{
16
return
true
;
17
}
18
if
(!(
value
is
string
text
))
19
{
20
return
false
;
21
}
22
string
text2 =
text
.Replace(
"-"
,
string
.
Empty
);
23
text2 = text2.Replace(
" "
,
string
.
Empty
);
24
int
num = 0;
25
bool
flag =
false
;
26
for
(
int
num2 = text2.Length - 1; num2 >= 0; num2--)
27
{
28
char
c = text2[num2];
29
if
(c <
'0'
|| c >
'9'
)
30
{
31
return
false
;
32
}
33
int
num3 = (c - 48) * ((!flag) ? 1 : 2);
34
flag = !flag;
35
while
(num3 > 0)
36
{
37
num += num3 % 10;
38
num3 /= 10;
39
}
40
}
41
return
num % 10 == 0;
42
}
43
}
System.ComponentModel.DataAnnotations.CreditCardAttribute.IsValid
override bool IsValid(object? value)
Definition
CreditCardAttribute.cs:12
System.ComponentModel.DataAnnotations.CreditCardAttribute.CreditCardAttribute
CreditCardAttribute()
Definition
CreditCardAttribute.cs:6
System.ComponentModel.DataAnnotations.CreditCardAttribute
Definition
CreditCardAttribute.cs:5
System.ComponentModel.DataAnnotations.DataTypeAttribute
Definition
DataTypeAttribute.cs:5
System.Empty
Definition
Empty.cs:4
System.SR.CreditCardAttribute_Invalid
static string CreditCardAttribute_Invalid
Definition
SR.cs:26
System.SR
Definition
SR.cs:7
System.ComponentModel.DataAnnotations.DataType
DataType
Definition
DataType.cs:4
System.ComponentModel.DataAnnotations.DataType.CreditCard
@ CreditCard
System.ComponentModel.DataAnnotations
Definition
ColumnAttribute.cs:3
System.ExceptionArgument.text
@ text
System.ExceptionArgument.value
@ value
System.AttributeTargets
AttributeTargets
Definition
AttributeTargets.cs:5
System
Definition
BlockingCollection.cs:8
source
System.ComponentModel.Annotations
System.ComponentModel.DataAnnotations
CreditCardAttribute.cs
Generated by
1.10.0