示例#1
0
 private static void InitData()
 {
     innerEnums = new System.Collections.Generic.Dictionary <System.Int32, CallResultEnum>();
     failure    = new CallResultEnum(0, "Failure");
     innerEnums.Add(0, failure);
     success = new CallResultEnum(1, "Success");
     innerEnums.Add(1, success);
     empty = new CallResultEnum(-1, "");
     innerEnums.Add(-1, empty);
 }
示例#2
0
 /// <summary>
 /// Get CallResultEnum By Value
 /// </summary>
 public static CallResultEnum GetFromValue(System.Int32 value)
 {
     //仅返回空的方法不是太好,在用的时候,枚举值可能就会设置一个枚举项中没有的,或者枚举值被删除.?
     if (!innerEnums.ContainsKey(value))
     {
         lock (lockobj)
         {
             if (!innerEnums.ContainsKey(value))
             {
                 CallResultEnum newValue = new CallResultEnum(value, "");
                 innerEnums.Add(value, newValue);
                 return(newValue);
             }
         }
     }
     return(innerEnums[value]);
 }