markus / License.Validator / ShowInLicenseInfoAttribute.cs @ master
이력 | 보기 | 이력해설 | 다운로드 (1.81 KB)
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
|
7 |
namespace License.Validator |
8 |
{ |
9 |
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] |
10 |
public class ShowInLicenseInfoAttribute : Attribute |
11 |
{ |
12 |
public enum FormatType |
13 |
{ |
14 |
String, |
15 |
Date, |
16 |
DateTime, |
17 |
EnumDescription, |
18 |
} |
19 |
|
20 |
protected bool _showInLicenseInfo = true; |
21 |
protected string _displayAs = string.Empty; |
22 |
protected FormatType _formatType = FormatType.String; |
23 |
|
24 |
public ShowInLicenseInfoAttribute() |
25 |
{ |
26 |
} |
27 |
|
28 |
public ShowInLicenseInfoAttribute(bool showInLicenseInfo) |
29 |
{ |
30 |
if (showInLicenseInfo) |
31 |
{ |
32 |
throw new Exception("When ShowInLicenseInfo is True, DisplayAs MUST have a value"); |
33 |
} |
34 |
_showInLicenseInfo = showInLicenseInfo; |
35 |
} |
36 |
|
37 |
public ShowInLicenseInfoAttribute(bool showInLicenseInfo, string displayAs) |
38 |
{ |
39 |
_showInLicenseInfo = showInLicenseInfo; |
40 |
_displayAs = displayAs; |
41 |
} |
42 |
public ShowInLicenseInfoAttribute(bool showInLicenseInfo, string displayAs, FormatType dataFormatType) |
43 |
{ |
44 |
_showInLicenseInfo = showInLicenseInfo; |
45 |
_displayAs = displayAs; |
46 |
_formatType = dataFormatType; |
47 |
} |
48 |
|
49 |
public bool ShowInLicenseInfo |
50 |
{ |
51 |
get |
52 |
{ |
53 |
return _showInLicenseInfo; |
54 |
} |
55 |
} |
56 |
|
57 |
public string DisplayAs |
58 |
{ |
59 |
get |
60 |
{ |
61 |
return _displayAs; |
62 |
} |
63 |
} |
64 |
|
65 |
public FormatType DataFormatType |
66 |
{ |
67 |
get |
68 |
{ |
69 |
return _formatType; |
70 |
} |
71 |
} |
72 |
} |
73 |
} |