forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefaultAttribute.cs
More file actions
42 lines (35 loc) · 1.17 KB
/
DefaultAttribute.cs
File metadata and controls
42 lines (35 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
namespace ServiceStack.DataAnnotations
{
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field)]
public class DefaultAttribute : AttributeBase
{
public int IntValue { get; set; }
public double DoubleValue { get; set; }
public Type DefaultType { get; set; }
public string DefaultValue { get; set; }
public bool OnUpdate { get; set; }
public DefaultAttribute(int intValue)
{
this.IntValue = intValue;
this.DefaultType = typeof(int);
this.DefaultValue = this.IntValue.ToString();
}
public DefaultAttribute(double doubleValue)
{
this.DoubleValue = doubleValue;
this.DefaultType = typeof(double);
this.DefaultValue = doubleValue.ToString();
}
public DefaultAttribute(string defaultValue)
{
this.DefaultType = typeof(string);
this.DefaultValue = defaultValue;
}
public DefaultAttribute(Type defaultType, string defaultValue)
{
this.DefaultValue = defaultValue;
this.DefaultType = defaultType;
}
}
}