コード例 #1
0
        public void Load()
        {
            var files = _service.GetPluginFiles();

            if (files.Any())
            {
                foreach (var file in files.Where(f => File.Exists(f)))
                {
                    var assembly = Assembly.LoadFile(file);
                    var modules  = assembly.GetExportedTypes()
                                   .Where(t => t.IsAbstract == false &&
                                          t.GetInterfaces().Contains(ModuleInterfaceType))
                                   .ToArray();

                    foreach (var module in modules)
                    {
                        Plugin plugin = new Plugin();
                        plugin.Assembly = assembly.GetName().FullName;
                        plugin.Module   = (INinjectModule)Activator.CreateInstance(module);
                        plugin.Version  = assembly.GetName().Version;

                        _manager.Connect(plugin);
                    }
                }
            }
        }
コード例 #2
0
        public void Load()
        {
            foreach (var module in _modules)
            {
                var assembly = module.GetType().Assembly;

                Plugin plugin = new Plugin();
                plugin.Assembly = assembly.GetName().FullName;
                plugin.Module   = module;
                plugin.Version  = assembly.GetName().Version;

                _manager.Connect(plugin);
            }
        }