CSVAttribute.cs
1.1 KB
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)
//{
// FieldName = fieldName;
//}
public string[] FiledNames { get; set; }
public string FieldName { get; set; }
public bool IsMustHave { get; set; }
}
}