Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        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);
        }