コード例 #1
0
        public override void OnExecute(IPluginProvider provider)
        {
            // Get configuration values
            var resource = SecureConfig.GetValue <string>("resource");
            var username = SecureConfig.GetValue <string>("username");
            var password = SecureConfig.GetValue <string>("password");

            // Get access token
            var token = provider.TokenService.GetToken(resource, username, password);

            // Get current versions
            var current  = GetCurrentVersions(token);
            var previous = GetPreviousVersions(provider.OrganizationAdminService);

            var isUpdated = current.Application > previous.Application || current.Database > previous.Database;

            if (isUpdated)
            {
                var entity = new Entity("bg_versionlog")
                {
                    ["bg_application"] = current.Application.ToString(),
                    ["bg_database"]    = current.Database.ToString()
                };
                provider.OrganizationAdminService.Create(entity);
            }

            var output = provider.ExecutionContext.OutputParameters;

            output["Application"] = current.Application.ToString();
            output["Database"]    = current.Database.ToString();
            output["IsUpdated"]   = isUpdated;
        }
コード例 #2
0
        public override void Loaded(IPluginProvider pluginProvider)
        {
            _auth           = pluginProvider.Get <AuthPlugin>();
            _auth.LoggedIn += OnLoggedIn;

            database = pluginProvider.Get <CockroachDbPlugin>();
        }
コード例 #3
0
        public ScanAgent(
            [NotNull] IApiService service,
            [NotNull] ILog logger,
            [NotNull] IPluginProvider pluginProvider,
            [NotNull] IScanAgentIdProvider scanAgentIdProvider,
            [NotNull] ISystemVersionProvider systemVersionProvider)
        {
            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (pluginProvider == null)
            {
                throw new ArgumentNullException(nameof(pluginProvider));
            }
            if (scanAgentIdProvider == null)
            {
                throw new ArgumentNullException(nameof(scanAgentIdProvider));
            }
            if (systemVersionProvider == null)
            {
                throw new ArgumentNullException(nameof(systemVersionProvider));
            }

            _apiService            = service;
            _logger                = logger;
            _pluginProvider        = pluginProvider;
            _scanAgentIdProvider   = scanAgentIdProvider;
            _systemVersionProvider = systemVersionProvider;
        }
コード例 #4
0
 public PluginManager(IPluginProvider pluginService, ILog log) {
   this.pluginService = pluginService;
   this.log = log;
   CheckWorkingDirectories();
   PluginCacheDir = CoreProperties.Settings.Default.PluginCacheDir;
   PluginTempBaseDir = CoreProperties.Settings.Default.PluginTempBaseDir;
   DoUpdateRun();
 }
コード例 #5
0
        public static IServiceCollection AddPluginProvider(this IServiceCollection pool)
        {
            IServiceProvider services = pool.GetDescriptor <IServiceProvider>().GetInstance() as IServiceProvider;
            IPluginProvider  provider = services.CreateInstance <PluginProvider>();

            pool.Add(ServiceDescriptor.Singleton <IPluginProvider>(provider));
            return(pool);
        }
コード例 #6
0
 public PluginManager(IPluginProvider pluginService, ILog log)
 {
     this.pluginService = pluginService;
     this.log           = log;
     CheckWorkingDirectories();
     PluginCacheDir    = CoreProperties.Settings.Default.PluginCacheDir;
     PluginTempBaseDir = CoreProperties.Settings.Default.PluginTempBaseDir;
     DoUpdateRun();
 }
コード例 #7
0
        public GetPluginsByProjectQueryHandler([NotNull] IPluginProvider pluginsProvider)
        {
            if (pluginsProvider == null)
            {
                throw new ArgumentNullException(nameof(pluginsProvider));
            }

            _pluginsProvider = pluginsProvider;
        }
コード例 #8
0
        public override void OnExecute(IPluginProvider provider)
        {
            // Get configuration values
            var resource = SecureConfig.GetValue <string>("resource");
            var username = SecureConfig.GetValue <string>("username");
            var password = SecureConfig.GetValue <string>("password");

            var renderer = new Renderer(resource, username, password);

            var service = provider.OrganizationService;
            var context = provider.ExecutionContext;
            var target  = provider.Target;

            // Render the report
            var output = string.Empty;

            switch (target.LogicalName)
            {
            case "report":
                var reportColumns = new ColumnSet("reportnameonsrs", "languagecode", "defaultfilter");
                var report        = service.Retrieve(target.LogicalName, target.Id, reportColumns);
                var format        = context.InputParameterOrDefault <string>("Format");
                var parameters    = context.InputParameterOrDefault <string>("Parameters");
                var rendered      = renderer.RenderReport(report, format, parameters);
                output = Convert.ToBase64String(rendered);
                break;

            case "documenttemplate":
                var templateColumns = new ColumnSet("documenttype", "associatedentitytypecode");
                var template        = service.Retrieve(target.LogicalName, target.Id, templateColumns);

                switch (template.GetAttributeValue <OptionSetValue>("documenttype")?.Value)
                {
                case 1:
                    var savedView = Guid.Parse(context.InputParameterOrDefault <string>("ViewId"));
                    output = renderer.RenderExcelTemplate(template.Id, savedView);
                    break;

                case 2:
                    var typeCode = template.GetAttributeValue <string>("associatedentitytypecode");
                    var metadata = service.GetEntityMetadata(typeCode);
                    var recordId = Guid.Parse(context.InputParameterOrDefault <string>("RecordId"));
                    output = renderer.RenderWordTemplate(template.Id, recordId, metadata.ObjectTypeCode ?? 0);
                    break;

                default:
                    throw new Exception("Invalid document template type.");
                }
                break;

            default:
                throw new Exception("Invalid input target.");
            }
            // Return as Base-64
            provider.ExecutionContext.OutputParameters["Output"] = output;
        }
コード例 #9
0
ファイル: PluginManager.cs プロジェクト: zhangzheng12/EApp
        public PluginManager(IPluginProvider pluginProvider, IPluginServiceProvider serviceProvider)
        {
            this.pluginProvider = pluginProvider;

            this.serviceProvider = serviceProvider;

            this.pluginControllers = new PluginControllerCollection <TPluginItem>();

            this.serviceProvider.AddService(typeof(IPluginManager <>), this);
        }
コード例 #10
0
        public PluginHost(IPluginProvider pluginProvider, TServiceProviderFactory serviceProver)
        {
            this.serviceProvider = serviceProver;

            this.pluginProvider = pluginProvider;

            this.pluginManager = new PluginManager <TPluginItem>(this.pluginProvider, this.serviceProvider.ServiceProvider);

            this.pluginManager.PluginAdded -= new EventHandler <EventArgs <TPluginItem> >(this.OnPluginAdded);
            this.pluginManager.PluginAdded += new EventHandler <EventArgs <TPluginItem> >(this.OnPluginAdded);
        }
コード例 #11
0
        public override void Loaded(IPluginProvider pluginProvider)
        {
            //Setup auth dependencies
            var auth = pluginProvider.Get <AuthPlugin>();

            if (UseAuthModule && auth != null)
            {
                auth.LoggedIn  += OnUserLoggedIn;
                auth.LoggedOut += OnUserLoggedOut;
            }
        }
コード例 #12
0
        public CoreNavigationForm(IPluginProvider pluginProvider, IResourceManager resourceManager)
        {
            InitializeComponent();

            this.pluginProvider = pluginProvider;

            this.resourceManager = resourceManager;

            this.InitializeRibbonMenu();

            this.PopulateRibbonMenuButtons();
        }
コード例 #13
0
ファイル: Program.cs プロジェクト: VideoGameRoulette/SRTHost
        private static IEnumerable <IPlugin> CreatePlugins(Assembly assembly)
        {
            int count = 0;

            Type[] typesInAssembly = null;

            try
            {
                typesInAssembly = assembly.GetTypes();
            }
            catch (Exception ex)
            {
            }

            foreach (Type type in typesInAssembly)
            {
                if (typeof(IPluginProvider).IsAssignableFrom(type))
                {
                    IPluginProvider result = Activator.CreateInstance(type) as IPluginProvider;
                    if (result != null)
                    {
                        count++;
                        yield return(result);
                    }
                }
                else if (typeof(IPluginUI).IsAssignableFrom(type))
                {
                    IPluginUI result = Activator.CreateInstance(type) as IPluginUI;
                    if (result != null)
                    {
                        count++;
                        yield return(result);
                    }
                }
                else if (typeof(IPlugin).IsAssignableFrom(type))
                {
                    IPlugin result = Activator.CreateInstance(type) as IPlugin;
                    if (result != null)
                    {
                        count++;
                        yield return(result);
                    }
                }
            }

            //if (count == 0)
            //{
            //    string availableTypes = string.Join(",", assembly.GetTypes().Select(t => t.FullName));
            //    throw new ApplicationException(
            //        $"Can't find any type which implements ISRTPlugin in {assembly} from {assembly.Location}.\n" +
            //        $"Available types: {availableTypes}");
            //}
        }
コード例 #14
0
ファイル: CoreNavigationForm.cs プロジェクト: daywrite/EApp
        public CoreNavigationForm(IPluginProvider pluginProvider, IResourceManager resourceManager)
        {
            InitializeComponent();

            this.pluginProvider = pluginProvider;

            this.resourceManager = resourceManager;

            this.InitializeRibbonMenu();

            this.PopulateRibbonMenuButtons();
        }
コード例 #15
0
ファイル: PluginManager.cs プロジェクト: oliver4888/Obsidian
        /// <summary>
        /// Loads a plugin from selected path asynchronously.
        /// </summary>
        /// <param name="path">Path to load the plugin from. Can point either to local <b>DLL</b>, <b>C# code file</b> or a <b>GitHub project url</b>.</param>
        /// <param name="permissions">Permissions granted to the plugin.</param>
        /// <returns>Loaded plugin. If loading failed, <see cref="PluginContainer.Plugin"/> property will be null.</returns>
        public async Task <PluginContainer> LoadPluginAsync(string path, PluginPermissions permissions)
        {
            IPluginProvider provider = PluginProviderSelector.GetPluginProvider(path);

            if (provider == null)
            {
                logger?.LogError($"Couldn't load plugin from path '{path}'");
                return(null);
            }

            PluginContainer plugin = await provider.GetPluginAsync(path, logger).ConfigureAwait(false);

            return(HandlePlugin(plugin, permissions));
        }
コード例 #16
0
ファイル: PluginManager.cs プロジェクト: oliver4888/Obsidian
        /// <summary>
        /// Loads a plugin from selected path.
        /// <br/><b>Important note:</b> keeping references to plugin containers outside this class will make them unloadable.
        /// </summary>
        /// <param name="path">Path to load the plugin from. Can point either to local <b>DLL</b>, <b>C# code file</b> or a <b>GitHub project url</b>.</param>
        /// <param name="permissions">Permissions granted to the plugin.</param>
        /// <returns>Loaded plugin. If loading failed, <see cref="PluginContainer.Plugin"/> property will be null.</returns>
        public PluginContainer LoadPlugin(string path, PluginPermissions permissions)
        {
            IPluginProvider provider = PluginProviderSelector.GetPluginProvider(path);

            if (provider == null)
            {
                logger?.LogError($"Couldn't load plugin from path '{path}'");
                return(null);
            }

            PluginContainer plugin = provider.GetPlugin(path, logger);

            return(HandlePlugin(plugin, permissions));
        }
コード例 #17
0
        public PluginAssemblyCache(IPluginProvider pluginProvider, PluginLoader pluginLoader)
        {
            if (pluginProvider == null)
            {
                throw new ArgumentNullException("pluginProvider");
            }
            _PluginProvider = pluginProvider;

            if (pluginLoader == null)
            {
                throw new ArgumentNullException("pluginLoader");
            }
            _PluginLoader = pluginLoader;
        }
コード例 #18
0
        public virtual void Initialize()
        {
            CurrentPlatform = Container.GetInstance <IPlatformProvider>().GetPlatform();

            Container.GetInstance <IViewModelFactory>().Initialize();
            Container.GetInstance <IViewFactory>().Initialize();
            Container.GetInstance <IServiceDispatcher>().Initialize();

            pluginProvider = Container.GetInstance <IPluginProvider>();

            serviceDispatcher = Container.GetInstance <IServiceDispatcher>();
            serviceDispatcher.Subscribe <IShellNavigationService>(this);

            Run();
        }
コード例 #19
0
 public GetSystemSettingsQueryHandler(
     IConfigManager configManager,
     IConfigurationProvider configurationProvider,
     IMailConnectionParametersProvider mailConnectionParametersProvider,
     IPluginProvider pluginProvider,
     IScanAgentRepository scanAgentRepository,
     IUserAuthorityValidator userAuthorityValidator,
     IUserPrincipal userPrincipal)
 {
     _configManager                    = configManager;
     _configurationProvider            = configurationProvider;
     _mailConnectionParametersProvider = mailConnectionParametersProvider;
     _pluginProvider                   = pluginProvider;
     _scanAgentRepository              = scanAgentRepository;
     _userAuthorityValidator           = userAuthorityValidator;
     _userPrincipal                    = userPrincipal;
 }
コード例 #20
0
 public void Unsubscribe(IPluginProvider provider)
 {
     provider.PreTestInitEvent        -= PreTestInit;
     provider.TestInitFailedEvent     -= TestInitFailed;
     provider.PostTestInitEvent       -= PostTestInit;
     provider.PreTestCleanupEvent     -= PreTestCleanup;
     provider.PostTestCleanupEvent    -= PostTestCleanup;
     provider.TestCleanupFailedEvent  -= TestCleanupFailed;
     provider.PreTestsArrangeEvent    -= PreTestsArrange;
     provider.TestsArrangeFailedEvent -= TestsArrangeFailed;
     provider.PreTestsActEvent        -= PreTestsAct;
     provider.PostTestsActEvent       -= PostTestsAct;
     provider.PostTestsArrangeEvent   -= PostTestsArrange;
     provider.PreTestsCleanupEvent    -= PreTestsCleanup;
     provider.PostTestsCleanupEvent   -= PostTestsCleanup;
     provider.TestsCleanupFailedEvent -= TestsCleanupFailed;
 }
コード例 #21
0
        public override void OnExecute(IPluginProvider provider)
        {
            // Get services
            var logger  = provider.LoggingService;
            var service = provider.OrganizationService;
            var context = provider.ExecutionContext;

            var report = service.Retrieve(context.PrimaryEntityName, context.PrimaryEntityId, new ColumnSet("originalbodytext"));
            var body   = report.GetAttributeValue <string>("originalbodytext");

            var serializer = new XmlSerializer(typeof(Report));

            using (var reader = new StringReader(body))
            {
                var r = serializer.Deserialize(reader) as Report;

                context.OutputParameters["Parameters"] = string.Join(", ", r.ReportParameters.Select(x => x.Name));
            }
        }
コード例 #22
0
        public static IEnumerable <IPlugin> CreatePlugins(Assembly assembly)
        {
            int count = 0;

            Type[] typesInAssembly = null;

            try
            {
                typesInAssembly = assembly.GetTypes();
            }
            catch (Exception ex)
            {
                Program.HandleException(ex);
                yield break;
            }

            if (typesInAssembly != null)
            {
                foreach (Type type in typesInAssembly)
                {
                    if (type.GetInterface(nameof(IPluginProvider)) != null)
                    {
                        IPluginProvider result = (IPluginProvider)Activator.CreateInstance(type); // If this throws an exception, the plugin may be targeting a different version of SRTPluginBase.
                        count++;
                        yield return(result);
                    }
                    else if (type.GetInterface(nameof(IPluginUI)) != null)
                    {
                        IPluginUI result = (IPluginUI)Activator.CreateInstance(type);
                        count++;
                        yield return(result);
                    }
                    else if (type.GetInterface(nameof(IPlugin)) != null)
                    {
                        IPlugin result = (IPlugin)Activator.CreateInstance(type);
                        count++;
                        yield return(result);
                    }
                }
            }
        }
コード例 #23
0
        public void Start()
        {
            SpeedDateConfig.Initialize(_configFile);
            var logger = LogManager.GetLogger("SpeedDate");
            var kernel = CreateKernel();

            var startable = kernel.Get <ISpeedDateStartable>();

            startable.Started += () => Started?.Invoke();
            startable.Stopped += () => Stopped?.Invoke();

            PluginProver = kernel.Get <IPluginProvider>();

            foreach (var plugin in kernel.GetAll <IPlugin>())
            {
                PluginProver.RegisterPlugin(plugin);
            }

            foreach (var plugin in PluginProver.GetAll())
            {
                plugin.Loaded(PluginProver);
                logger.Info($"Loaded {plugin.GetType().Name}");
            }

            var server = kernel.TryGet <IServer>();

            if (server != null)
            {
                logger.Info("Acting as server: " + server.GetType().Name);
            }

            var client = kernel.TryGet <IClient>();

            if (client != null)
            {
                logger.Info("Acting as client: " + client.GetType().Name);
            }

            startable.Start();
        }
コード例 #24
0
        public PluginInitializer(
            [NotNull] ILog log,
            [NotNull] IPluginLoader <IPlugin> pluginLoader,
            [NotNull] IPluginProvider pluginProvider)
        {
            if (log == null)
            {
                throw new ArgumentNullException(nameof(log));
            }

            if (pluginLoader == null)
            {
                throw new ArgumentNullException(nameof(pluginLoader));
            }

            if (pluginProvider == null)
            {
                throw new ArgumentNullException(nameof(pluginProvider));
            }

            _log            = log;
            _pluginLoader   = pluginLoader;
            _pluginProvider = pluginProvider;
        }
コード例 #25
0
        public void SetUp()
        {
            _testPlugin = new Mock <IVersionControlPlugin>();

            _licenceProvider = new Mock <ILicenceProvider>();

            var licence = new Mock <ILicence>();

            licence.Setup(_ => _.Get <PluginLicenceComponent>()).Returns(new PluginLicenceComponent());

            _licenceProvider.Setup(_ => _.GetCurrent()).Returns(licence.Object);

            _log = new Mock <ILog>();
            _pluginContainerProvider = new Mock <IPluginContainerManager>();
            _pluginRepository        = new Mock <IPluginRepository>();
            _pluginSettingProvider   = new Mock <IPluginSettingProvider>();

            _target = new PluginProvider(
                _licenceProvider.Object,
                _log.Object,
                _pluginContainerProvider.Object,
                _pluginRepository.Object,
                _pluginSettingProvider.Object);
        }
コード例 #26
0
 public void SetExtensionProperties(IPluginProvider importProvider,
     IMLSection section, bool isFirstLoad)
 {
     ImportProvider = importProvider;
     Section = section;
     IsFirstLoad = isFirstLoad;
 }
コード例 #27
0
        public App(IConfigSource configSource)
        {
            #region Check whether the required or mandatory EApp configuration has been configured in config file.

            if (configSource == null)
            {
                throw new ArgumentNullException("configSource");
            }

            if (configSource.Config == null)
            {
                throw new ConfigException("EAppConfigSource has not been defined in the ConfigSource instance.");
            }

            if (configSource.Config.ObjectContainer == null)
            {
                throw new ConfigException("No ObjectContainer instance has been specified in the EAppConfigSource.");
            }

            #endregion

            this.configSource = configSource;

            #region If default used object container (i.e. default used IOC component) has been configured in config file then create it by Activator.CreateInstance

            string objectContainerFactoryProviderName = configSource.Config.ObjectContainer.Provider;

            if (string.IsNullOrEmpty(objectContainerFactoryProviderName) ||
                objectContainerFactoryProviderName.IsNullOrWhiteSpace())
            {
                throw new ConfigException("The ObjectContainer provider has not been defined in the ConfigSource.");
            }

            Type objectContainerFactoryType = Type.GetType(objectContainerFactoryProviderName);

            if (objectContainerFactoryType == null)
            {
                throw new InfrastructureException("The ObjectContainer defined by type {0} doesn't exist.", objectContainerFactoryProviderName);
            }

            IObjectContainerFactory currentObjectContainerFactory = (IObjectContainerFactory)Activator.CreateInstance(objectContainerFactoryType);

            if (currentObjectContainerFactory != null)
            {
                this.objectContainer = currentObjectContainerFactory.ObjectContainer;
            }

            // if object container need to be initialized from config file. E.g. Unity from config file.
            if (this.configSource.Config.ObjectContainer.InitFromConfigFile)
            {
                string sectionName = this.configSource.Config.ObjectContainer.SectionName;

                string configFilePath = this.configSource.Config.ObjectContainer.File;

                if (!string.IsNullOrEmpty(sectionName) && !sectionName.IsNullOrWhiteSpace())
                {
                    this.objectContainer.InitializeFromConfigFile(sectionName, configFilePath);
                }
                else
                {
                    throw new ConfigException("Section name for the ObjectContainer configuration should also be provided when InitFromConfigFile has been set to true.");
                }
            }

            #endregion

            #region if resource managers have been configured in config file then create these resource managers

            if (configSource.Config.ResourceManagers != null &&
                configSource.Config.ResourceManagers.ElementInformation.IsPresent)
            {
                foreach (NameTypeElement resourceItem in configSource.Config.ResourceManagers)
                {
                    string resourceName = resourceItem.Name;

                    string resourceAssemblyName = resourceItem.Type;

                    if (!string.IsNullOrEmpty(resourceName) &&
                        !string.IsNullOrEmpty(resourceAssemblyName))
                    {
                        Type resourceAssemblyType = Type.GetType(resourceAssemblyName);

                        if (resourceAssemblyType == null)
                        {
                            continue;
                        }

                        this.ObjectContainer.RegisterType <IResourceManager>(resourceAssemblyType, resourceName);

                        this.resourceManagers.Add(resourceName, this.ObjectContainer.Resolve <IResourceManager>(resourceName));
                    }
                }
            }

            #endregion

            #region If module plugin architecture has been configured in config file then create plugin host, plugin provider and service provider

            if (configSource.Config.PluginContainer != null &&
                configSource.Config.PluginContainer.ElementInformation.IsPresent &&
                configSource.Config.PluginContainer.Host != null &&
                configSource.Config.PluginContainer.Host.ElementInformation.IsPresent)
            {
                if (configSource.Config.PluginContainer.Host.ServiceProvider == null)
                {
                    throw new ConfigException("Plugin Service Provider configuration has not been initialized in the ConfigSource instance.");
                }

                if (configSource.Config.PluginContainer.Host.PluginProvider == null)
                {
                    throw new ConfigException("Plugin Provider configuration has not been initialized in the ConfigSource instance.");
                }

                string hostTypeName = configSource.Config.PluginContainer.Host.Provider;

                if (string.IsNullOrEmpty(hostTypeName) ||
                    hostTypeName.IsNullOrWhiteSpace())
                {
                    throw new ConfigException("The Plugin Host Type Name has not been defined in the Plugin Config Source.");
                }

                string pluginProviderTypeName = configSource.Config.PluginContainer.Host.PluginProvider.Provider;

                if (string.IsNullOrEmpty(pluginProviderTypeName) ||
                    pluginProviderTypeName.IsNullOrWhiteSpace())
                {
                    throw new ConfigException("The Plugin Provider Type Name has not been defined in the Plugin Config Source.");
                }

                string serviceProviderFacotryTypeName = configSource.Config.PluginContainer.Host.ServiceProvider.Provider;

                if (string.IsNullOrEmpty(serviceProviderFacotryTypeName) ||
                    serviceProviderFacotryTypeName.IsNullOrWhiteSpace())
                {
                    throw new ConfigException("The Plugin Service Provider Type Name has not been defined in the Plugin Config Source.");
                }

                Type hostType = Type.GetType(hostTypeName);

                if (hostType == null)
                {
                    throw new InfrastructureException("The Plugin Host defined by type {0} doesn't exist.", hostTypeName);
                }

                Type pluginProviderType = Type.GetType(pluginProviderTypeName);

                if (pluginProviderType == null)
                {
                    throw new InfrastructureException("The Plugin Provider defined by type {0} doesn't exist.", pluginProviderTypeName);
                }

                Type serviceProviderFacotryType = Type.GetType(serviceProviderFacotryTypeName);

                if (serviceProviderFacotryType == null)
                {
                    throw new InfrastructureException("The Plugin Service Provider defined by type {0} doesn't exist.", serviceProviderFacotryTypeName);
                }

                IPluginProvider pluginProvider = (IPluginProvider)Activator.CreateInstance(pluginProviderType);

                IPluginServiceProviderFactory serviceProviderFactory = (IPluginServiceProviderFactory)Activator.CreateInstance(serviceProviderFacotryType, new object[] { pluginProvider });

                this.pluginHost = (IHost)Activator.CreateInstance(hostType, new object[] { pluginProvider, serviceProviderFactory });

                // If plugin types have been configured in config file then register them into the object container for IOC.
                // e.g. when clicking a button to load a module plugin UI get the plugin instance by name from object container.
                if (configSource.Config.PluginContainer != null &&
                    configSource.Config.PluginContainer.ElementInformation.IsPresent &&
                    configSource.Config.PluginContainer.PluginRegisters != null &&
                    configSource.Config.PluginContainer.PluginRegisters.Count > 0)
                {
                    foreach (PluginRegisterElement pluginRegisterItem in configSource.Config.PluginContainer.PluginRegisters)
                    {
                        string pluginName = pluginRegisterItem.Name;

                        string pluginTypeName = pluginRegisterItem.Type;

                        if (!string.IsNullOrEmpty(pluginName) &&
                            !string.IsNullOrEmpty(pluginTypeName))
                        {
                            Type pluginAssemblyType = Type.GetType(pluginTypeName);

                            if (pluginAssemblyType == null)
                            {
                                continue;
                            }

                            this.ObjectContainer.RegisterType(typeof(IPlugin), pluginAssemblyType, pluginName);
                        }
                    }
                }
            }

            #endregion

            #region If windows mvc controller list have been configured in config file then register controller type

            if (configSource.Config.WindowsMvc != null &&
                configSource.Config.WindowsMvc.ElementInformation.IsPresent &&
                configSource.Config.WindowsMvc.Controllers != null)
            {
                foreach (NameTypeElement controllerRegisterItem in configSource.Config.WindowsMvc.Controllers)
                {
                    string controllerName = controllerRegisterItem.Name;

                    string controllerTypeName = controllerRegisterItem.Type;

                    if (!string.IsNullOrEmpty(controllerName) &&
                        !string.IsNullOrEmpty(controllerTypeName))
                    {
                        Type controllerAssemblyType = Type.GetType(controllerTypeName);

                        if (controllerAssemblyType == null)
                        {
                            continue;
                        }

                        this.ObjectContainer.RegisterType(typeof(IController), controllerAssemblyType, controllerName);
                    }
                }
            }

            #endregion
        }
コード例 #28
0
ファイル: Program.cs プロジェクト: VideoGameRoulette/SRTHost
        //[STAThread]
        public static async Task Main()
        {
            Console.CancelKeyPress += (object sender, ConsoleCancelEventArgs e) =>
            {
                e.Cancel = true;
                running  = false;
            };

            IPlugin[]       allPlugins     = null;
            IPluginProvider providerPlugin = null;

            IPluginUI[] uiPlugins = null;
            try
            {
                allPlugins = new DirectoryInfo("plugins")
                             .EnumerateDirectories("*", SearchOption.TopDirectoryOnly)
                             .Select((DirectoryInfo pluginDir) => pluginDir.EnumerateFiles(string.Format("{0}.dll", pluginDir.Name), SearchOption.TopDirectoryOnly).First())
                             .Select(a => a.FullName)
                             .SelectMany((string pluginPath) =>
                {
                    Assembly pluginAssembly = LoadPlugin(pluginPath);
                    return(CreatePlugins(pluginAssembly));
                }).ToArray();

                if (allPlugins.Count(a => typeof(IPluginProvider).IsAssignableFrom(a.GetType())) > 1)
                {
                    Environment.Exit(1); // Critical error. Handle better. Only one provider allowed.
                }
                providerPlugin = (IPluginProvider)allPlugins.First(a => typeof(IPluginProvider).IsAssignableFrom(a.GetType()));
                uiPlugins      = allPlugins.Where(a => typeof(IPluginUI).IsAssignableFrom(a.GetType())).Select(a => (IPluginUI)a).ToArray();

                // Startup.
                foreach (IPlugin plugin in allPlugins)
                {
                    int pluginStartupStatus = 0;
                    try
                    {
                        pluginStartupStatus = plugin.Startup(hostDelegates);

                        if (pluginStartupStatus == 0)
                        {
                            Console.WriteLine("[{0} v{1}.{2}.{3}.{4}] successfully started.", plugin.Info.Name, plugin.Info.VersionMajor, plugin.Info.VersionMinor, plugin.Info.VersionBuild, plugin.Info.VersionRevision);
                        }
                        else
                        {
                            Console.WriteLine("[{0} v{1}.{2}.{3}.{4}] failed to start properly with status {5}.", plugin.Info.Name, plugin.Info.VersionMajor, plugin.Info.VersionMinor, plugin.Info.VersionBuild, plugin.Info.VersionRevision, pluginStartupStatus);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("[{0}] {1}", ex.GetType().Name, ex.ToString());
                    }
                }

                Console.WriteLine("Press CTRL+C in this console window to shutdown the SRT.");
                while (running)
                {
                    object gameMemory = providerPlugin.PullData();
                    if (gameMemory != null)
                    {
                        foreach (IPluginUI uiPlugin in uiPlugins)
                        {
                            int uiPluginReceiveDataStatus = 0;
                            try
                            {
                                uiPluginReceiveDataStatus = uiPlugin.ReceiveData(gameMemory);
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine("[{0}] {1}", ex.GetType().Name, ex.ToString());
                            }
                        }
                    }
                    await Task.Delay(16).ConfigureAwait(false);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("[{0}] {1}", ex.GetType().Name, ex.ToString());
            }
            finally
            {
                // Shutdown.
                foreach (IPlugin plugin in allPlugins)
                {
                    int pluginShutdownStatus = 0;
                    try
                    {
                        pluginShutdownStatus = plugin.Shutdown();
                        if (pluginShutdownStatus == 0)
                        {
                            Console.WriteLine("[{0} v{1}.{2}.{3}.{4}] successfully shutdown.", plugin.Info.Name, plugin.Info.VersionMajor, plugin.Info.VersionMinor, plugin.Info.VersionBuild, plugin.Info.VersionRevision);
                        }
                        else
                        {
                            Console.WriteLine("[{0} v{1}.{2}.{3}.{4}] failed to stop properly with status {5}.", plugin.Info.Name, plugin.Info.VersionMajor, plugin.Info.VersionMinor, plugin.Info.VersionBuild, plugin.Info.VersionRevision, pluginShutdownStatus);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("[{0}] {1}", ex.GetType().Name, ex.ToString());
                    }
                }
            }
        }
コード例 #29
0
        public override void Loaded(IPluginProvider pluginProvider)
        {
            base.Loaded(pluginProvider);

            _roomPlugin = pluginProvider.Get <RoomPlugin>();
        }
コード例 #30
0
 public HomeController(IPluginProvider _provider, ILogger <HomeController> _log)
 {
     provider = _provider;
     log      = _log;
 }
コード例 #31
0
 public FileSystemWatchingRunner(INotificationService notificationService, IPluginProvider pluginProvider)
 {
     this.notificationService = notificationService;
     this.pluginProvider = pluginProvider;
     this.pluginRunner = new PluginRunner();
 }
コード例 #32
0
 public abstract void OnExecute(IPluginProvider provider);
コード例 #33
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PluginProviderProxy{T}"/> class.
 /// </summary>
 public PluginProviderProxy(T pluginConfiguration, IPluginProvider <T> pluginProvider)
 {
     _pluginConfiguration = pluginConfiguration;
     _pluginProvider      = pluginProvider;
 }
コード例 #34
0
        public CreateProjectCommandHandler(
            [NotNull] IAuthorityProvider authorityProvider,
            [NotNull] INotificationRuleProvider notificationRuleProvider,
            [NotNull] IUserAuthorityValidator userAuthorityValidator,
            [NotNull] IProjectRepository repositoryProjects,
            [NotNull] IRoleProvider roleProvider,
            [NotNull] ISdlPolicyProvider sdlPolicyProvider,
            [NotNull] ITimeService timeService,
            [NotNull] IUnitOfWork unitOfWork,
            [NotNull] IUserPrincipal userPrincipal,
            [NotNull] IQueryRepository queryRepository,
            [NotNull] IReportRepository reportRepository,
            [NotNull] ILicenceProvider licenceProvider,
            [NotNull] IPluginProvider pluginProvider,
            [NotNull] ITelemetryScopeProvider telemetryScopeProvider)
            : base(userAuthorityValidator, unitOfWork, userPrincipal)
        {
            if (authorityProvider == null)
            {
                throw new ArgumentNullException(nameof(authorityProvider));
            }
            if (notificationRuleProvider == null)
            {
                throw new ArgumentNullException(nameof(notificationRuleProvider));
            }
            if (userAuthorityValidator == null)
            {
                throw new ArgumentNullException(nameof(userAuthorityValidator));
            }
            if (repositoryProjects == null)
            {
                throw new ArgumentNullException(nameof(repositoryProjects));
            }
            if (roleProvider == null)
            {
                throw new ArgumentNullException(nameof(roleProvider));
            }
            if (sdlPolicyProvider == null)
            {
                throw new ArgumentNullException(nameof(sdlPolicyProvider));
            }
            if (timeService == null)
            {
                throw new ArgumentNullException(nameof(timeService));
            }
            if (userPrincipal == null)
            {
                throw new ArgumentNullException(nameof(userPrincipal));
            }
            if (queryRepository == null)
            {
                throw new ArgumentNullException(nameof(queryRepository));
            }
            if (reportRepository == null)
            {
                throw new ArgumentNullException(nameof(reportRepository));
            }
            if (licenceProvider == null)
            {
                throw new ArgumentNullException(nameof(licenceProvider));
            }
            if (pluginProvider == null)
            {
                throw new ArgumentNullException(nameof(pluginProvider));
            }
            if (telemetryScopeProvider == null)
            {
                throw new ArgumentNullException(nameof(telemetryScopeProvider));
            }

            _authorityProvider        = authorityProvider;
            _notificationRuleProvider = notificationRuleProvider;
            _repositoryProjects       = repositoryProjects;
            _roleProvider             = roleProvider;
            _sdlPolicyProvider        = sdlPolicyProvider;
            _userPrincipal            = userPrincipal;
            _queryRepository          = queryRepository;
            _reportRepository         = reportRepository;
            _licenceProvider          = licenceProvider;
            _pluginProvider           = pluginProvider;
            _telemetryScopeProvider   = telemetryScopeProvider;
            _timeService = timeService;
        }
コード例 #35
0
ファイル: XpressAppNav.cs プロジェクト: daywrite/EApp
 public XpressAppNav(IPluginProvider pluginProvider)
     : base(pluginProvider, new CommonResourceManager())
 {
     InitializeComponent();
 }
コード例 #36
0
 public XpressModulePluginHost(IPluginProvider pluginProvider, CoreNavigationForm serviceProvider)
     : base(pluginProvider, serviceProvider)
 {
 }