public List <EnumValueInfo> GetAccessTypesFromAssembly(Assembly assembly, MetadataCache cache) { ArgumentUtility.CheckNotNull("assembly", assembly); ArgumentUtility.CheckNotNull("cache", cache); List <EnumValueInfo> accessTypes = new List <EnumValueInfo> (); foreach (var type in AssemblyTypeCache.GetTypes(assembly)) { if (type.IsEnum && Attribute.IsDefined(type, typeof(AccessTypeAttribute), false)) { Dictionary <Enum, EnumValueInfo> values = _enumerationReflector.GetValues(type, cache); foreach (KeyValuePair <Enum, EnumValueInfo> entry in values) { if (!cache.ContainsAccessType(entry.Key)) { cache.AddAccessType(entry.Key, entry.Value); } accessTypes.Add(entry.Value); } } } return(accessTypes); }
public List <EnumValueInfo> GetAccessTypesFromType(Type type, MetadataCache cache) { ArgumentUtility.CheckNotNull("type", type); ArgumentUtility.CheckNotNull("cache", cache); Dictionary <Enum, EnumValueInfo> accessTypes = _enumerationReflector.GetValues(typeof(GeneralAccessTypes), cache); foreach (KeyValuePair <Enum, EnumValueInfo> entry in accessTypes) { if (!cache.ContainsAccessType(entry.Key)) { cache.AddAccessType(entry.Key, entry.Value); } } AddAccessTypes(type, accessTypes, cache); return(new List <EnumValueInfo> (accessTypes.Values)); }
private void AddAccessTypesFromAttribute(IEnumerable <MethodInfo> methodInfos, Dictionary <Enum, EnumValueInfo> accessTypes, MetadataCache cache) { foreach (var methodInfo in methodInfos) { var values = _permissionReflector.GetRequiredMethodPermissions(methodInfo.DeclaringType, MethodInfoAdapter.Create(methodInfo)); foreach (Enum value in values) { EnumValueInfo accessType = _enumerationReflector.GetValue(value, cache); if (!cache.ContainsAccessType(value)) { cache.AddAccessType(value, accessType); } if (!accessTypes.ContainsKey(value)) { accessTypes.Add(value, accessType); } } } }