public static List <XFrmWorkAttribute> GetPluginCollection( Type typeInterface, Assembly myAssembly, bool isAbstractRequired) { if (PluginDictionary.ContainsKey(typeInterface)) { return(PluginDictionary[typeInterface].ToList()); } var tc = new List <XFrmWorkAttribute>(); var types = myAssembly.GetTypes(); foreach (var type in types) { if (type.GetInterface(typeInterface.ToString()) == null) { continue; } if (!isAbstractRequired && type.IsAbstract) { continue; } // Iterate through all the Attributes for each method. foreach (Attribute attr in type.GetCustomAttributes(typeof(XFrmWorkAttribute), false)) { var attr2 = attr as XFrmWorkAttribute; attr2.MyType = type; tc.Add(attr2); } } PluginDictionary.Add(typeInterface, tc); return(tc); }
public static List <XFrmWorkAttribute> GetPluginCollection(Type typeInterface) { if (PluginDictionary.ContainsKey(typeInterface)) { return(PluginDictionary[typeInterface].ToList()); } var attrs = new List <XFrmWorkAttribute>(); foreach (var item in PluginDictionary) { foreach (var attribute in item.Value) { if (attribute.MyType.GetInterface(typeInterface.Name) != null && attrs.FirstOrDefault(d => d.Name == attribute.Name) == null) { attrs.Add(attribute); } } } PluginDictionary.Add(typeInterface, attrs); return(attrs); }