public enum 月定製項目
{
[CustomItemAttribute()]
一點五元夜餐次數=1,
[CustomItemAttribute()]
二元夜餐次數=2,
[CustomItemAttribute()]
連班次數 =3,
[CustomItemAttribute()]
甲類保健津貼次數 =4,
[CustomItemAttribute()]
乙類保健津貼次數 =5,
[CustomItemAttribute()]
周六加班次數 =6,
[CustomItemAttribute()]
周日加班次數 =7,
[CustomItemAttribute()]
零點夜班次數 =8,
[CustomItemAttribute()]
節假日加班次數 =9,
[CustomItemAttribute()]
四點夜班次數 =10,
[CustomItemAttribute()]
事假天數=11,
[CustomItemAttribute()]
病假天數 =12,
[CustomItemAttribute()]
曠工天數 =13,
[CustomItemAttribute()]
公差天數 =14,
[CustomItemAttribute()]
探親天數 =15,
[CustomItemAttribute(CustomApplyType.工區員工)]
效益工資 = 16
}
public enum CustomApplyType
{
工區員工 = 1,
機關員工 = 2,
所有員工 = 3
}
[AttributeUsage(AttributeTargets.Field)]
public class CustomItemAttribute:System.Attribute
{
protected CustomApplyType _customApplyType;
public CustomItemAttribute(CustomApplyType customApplyType)
{
this._customApplyType = customApplyType;
}
public CustomItemAttribute():this(CustomApplyType.所有員工)
{
}
public CustomApplyType CustomApplyType{get{return this._customApplyType;}}
}
class Application
{
[STAThread]
static void Main(string[] args)
{
FieldInfo[] fs = typeof(月定製項目).GetFields();
object enumInstance = typeof(月定製項目).Assembly.CreateInstance(typeof(月定製項目).FullName);
foreach(FieldInfo f in fs)
{
CustomItemAttribute[] cas = (CustomItemAttribute[])f.GetCustomAttributes(typeof(CustomItemAttribute),true);
if(cas.Length >0)
{
Console.WriteLine(f.GetValue(enumInstance));
Console.WriteLine(Convert.ToSingle((int)f.GetValue(enumInstance)));
Console.WriteLine(cas[0].CustomApplyType.ToString());
}
}
Console.Read();
}
}