/// <summary> /// Get CurrentNodeEnum By Value /// </summary> public static CurrentNodeEnum GetFromValue(System.Int32 value) { //仅返回空的方法不是太好,在用的时候,枚举值可能就会设置一个枚举项中没有的,或者枚举值被删除.? if (!innerEnums.ContainsKey(value)) { lock (lockobj) { if (!innerEnums.ContainsKey(value)) { CurrentNodeEnum newValue = new CurrentNodeEnum(value, ""); innerEnums.Add(value, newValue); return(newValue); } } } return(innerEnums[value]); }
private static void InitData() { innerEnums = new System.Collections.Generic.Dictionary <System.Int32, CurrentNodeEnum>(); notCommissioned = new CurrentNodeEnum(0, "NotCommissioned"); innerEnums.Add(0, notCommissioned); entrustedExecution = new CurrentNodeEnum(1, "EntrustedExecution"); innerEnums.Add(1, entrustedExecution); pendingPayment = new CurrentNodeEnum(2, "PendingPayment"); innerEnums.Add(2, pendingPayment); alreadyPaid = new CurrentNodeEnum(3, "AlreadyPaid"); innerEnums.Add(3, alreadyPaid); refunded = new CurrentNodeEnum(4, "Refunded"); innerEnums.Add(4, refunded); terminationEntrustment = new CurrentNodeEnum(5, "TerminationEntrustment"); innerEnums.Add(5, terminationEntrustment); empty = new CurrentNodeEnum(-1, ""); innerEnums.Add(-1, empty); }