CSVAttribute.cs
1.3 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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TSA_V.LoadCSVLibrary
{
//这里利用AttributeUsage 来设置我们的自定义属性的应用范围,这里定义的可以用于类,结构和方法的声明
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true)]
public class CSVAttribute : Attribute
{
public CSVAttribute(string fieldName,string filedName1, bool IsMust)
{
this.IsMustHave = IsMust;
FieldName = fieldName;
FiledNames = new string[] { filedName1 };
}
public CSVAttribute(string fieldName, bool IsMust= false,params string[] filedNames)
{
this.IsMustHave = IsMust;
FieldName = fieldName;
this.FiledNames = filedNames;
}
public CSVAttribute(string fieldName,bool IsMust)
{
this.IsMustHave = IsMust;
FieldName = fieldName;
}
public CSVAttribute(string fieldName)
{
FieldName = fieldName;
}
public string[] FiledNames { get; set; }
public string FieldName { get; set; }
public bool IsMustHave { get; set; }
}
}