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 TestAtgi() { PluginDictionary plugins = Singleton <PluginDictionary> .Instance; m_appPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // Setup schema path string schemaPath = Path.Combine(m_appPath, "schemas"); DomSchemaRegistry.SchemaResolver = new FileStreamResolver(schemaPath); // load atgi plugin string atgiPath = m_appPath + @"\Plugins\Scea.Atgi.pll"; Assembly assembly = Assembly.LoadFrom(atgiPath); plugins.Add(assembly); plugins.GetPlugins <PluginBase>(); // 2- create colleciton DomRepository repository = new DomRepository(); string atgiFile = m_appPath + @"\cube.atgi"; m_domCollection = repository.ReadCollection(new Uri(atgiFile)); m_domCollection.IsReadOnly = true; // add dc to DomRepository repository.Add(m_domCollection); }
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); }