public OperationTypeInfo(string type, OperationTypeAttribute info) { Type = type; DisplayName = info.DisplayName; TargetID_DisplayName_1 = info.TargetID_DisplayName_1; TargetID_DisplayName_2 = info.TargetID_DisplayName_2; TargetID_DisplayName_3 = info.TargetID_DisplayName_3; }
public static OperationTypeInfo[] GetOperationTypeInfos() { OperationTypeInfo[] result = null; if (CacheUtil.TryGetValue <OperationTypeInfo[]>("OperationTypeInfos", out result)) { return(result); } lock (s_GetOperationTypeInfoLocker) { if (CacheUtil.TryGetValue <OperationTypeInfo[]>("OperationTypeInfos", out result)) { return(result); } List <OperationTypeInfo> infos = new List <OperationTypeInfo>(); Hashtable flags = new Hashtable(); Assembly currentAssembly = Assembly.GetExecutingAssembly(); Type typeOfOperation = typeof(Operation); Type typeOfOperationTypeAttribute = typeof(OperationTypeAttribute); foreach (Type type in currentAssembly.GetTypes()) { if (type.IsDefined(typeOfOperationTypeAttribute, true) && type.IsSubclassOf(typeOfOperation)) { OperationTypeAttribute info = (OperationTypeAttribute)OperationTypeAttribute.GetCustomAttribute(type, typeof(OperationTypeAttribute), true); OperationTypeInfo i = new OperationTypeInfo(type.FullName, info); if (flags.ContainsKey(info.DisplayName) == false) { infos.Add(i); flags.Add(info.DisplayName, true); } } } infos.Sort(); result = infos.ToArray(); CacheUtil.Set <OperationTypeInfo[]>("OperationTypeInfos", result); return(result); } }