Пример #1
0
        private void Init(PluginsConfLoader pluginsConfLoader)
        {
            pluginsConfLoader.Loaded += (sender, args) =>
            {
                if (Container != null)
                {
                    Container.Dispose();
                }

                PluginsConf pluginsConf = args.PluginsConf;

                AggregateCatalog catalog = new AggregateCatalog();

                foreach (string plugins in pluginsConf.PluginsList)
                {
                    string   path     = Path.Combine(pluginsConf.PluginsDir, plugins);
                    Assembly assembly = Assembly.LoadFile(path);
                    catalog.Catalogs.Add(new AssemblyCatalog(assembly));
                }

                //Create the CompositionContainer with the parts in the catalog.
                Container = new CompositionContainer(catalog);

                //Fill the imports of this object
                Container.ComposeParts(GetComposedParts());
            };

            pluginsConfLoader.Load();
        }
Пример #2
0
        private void LoadPlugins()
        {
            string text = File.ReadAllText(_pluginsYmlFile);

            Deserializer deserializer = new Deserializer(namingConvention: new CamelCaseNamingConvention());

            PluginsConf pluginsConf = deserializer.Deserialize <PluginsConf>(new StringReader(text));

            OnPluginsLoaded(new PluginsConfLoadedEventArgs(pluginsConf));
        }