示例#1
0
        private static LoaderProperties GetLoaderProperties(string key, KraftModuleConfigurationSettings kraftConfigurationSettings, ELoaderType pluginType, bool isIterator = false)
        {
            LoaderProperties loaderProperties;

            switch (pluginType)
            {
            case ELoaderType.ViewLoader:
            {
                loaderProperties = kraftConfigurationSettings.NodeSetSettings.SourceLoaderMapping.ViewLoader.FirstOrDefault(n => n.Name.Equals(key, StringComparison.CurrentCultureIgnoreCase));
                break;
            }

            case ELoaderType.DataLoader:
            {
                if (isIterator)
                {
                    loaderProperties = kraftConfigurationSettings.NodeSetSettings.SourceLoaderMapping.NodesDataIterator.NodesDataIteratorConf;
                }
                else
                {
                    loaderProperties = kraftConfigurationSettings.NodeSetSettings.SourceLoaderMapping.NodesDataIterator.NodesDataLoader.FirstOrDefault(s => s.Name.Equals(key, StringComparison.CurrentCultureIgnoreCase));
                }
                break;
            }

            case ELoaderType.LookupLoader:
            {
                loaderProperties = kraftConfigurationSettings.NodeSetSettings.SourceLoaderMapping.LookupLoader.FirstOrDefault(n => n.Name.Equals(key, StringComparison.CurrentCultureIgnoreCase));
                break;
            }

            case ELoaderType.ResourceLoader:
            {
                loaderProperties = kraftConfigurationSettings.NodeSetSettings.SourceLoaderMapping.ResourceLoader.FirstOrDefault(n => n.Name.Equals(key, StringComparison.CurrentCultureIgnoreCase));
                break;
            }

            case ELoaderType.CustomPlugin:
            {
                loaderProperties = kraftConfigurationSettings.NodeSetSettings.SourceLoaderMapping.CustomPlugin.FirstOrDefault(n => n.Name.Equals(key, StringComparison.CurrentCultureIgnoreCase));
                break;
            }

            default:
            {
                throw new Exception("Plugintype is not known in Ccf.Ck.Processing.Execution.GetPlugin");
            }
            }
            return(loaderProperties);
        }
示例#2
0
        private void InitConfiguredPlugins(string moduleKey, string configFile, ICachingService cachingService)
        {
            //Init the kraft module configurations model
            ModuleSettings = new KraftModuleConfigurationSettings(_DependencyInjectionContainer, cachingService, _KraftGlobalConfigurationSettings);

            //read the module configuration
            IConfigurationBuilder configbuilder = new ConfigurationBuilder();

            configbuilder.SetBasePath(Path.GetDirectoryName(configFile)).AddJsonFile(configFile);
            IConfigurationRoot configurationRoot = configbuilder.Build();

            configurationRoot.Bind("KraftModuleConfigurationSettings", ModuleSettings);

            ModuleSettings.LoadDefinedObjects(moduleKey, configFile);
        }
示例#3
0
        private void InitConfiguredPlugins(string moduleKey, string configFile, ICachingService cachingService)
        {
            if (!File.Exists(configFile))
            {
                throw new FileNotFoundException($"The {configFile} file was not found!");
            }

            //Init the kraft module configurations model
            ModuleSettings = new KraftModuleConfigurationSettings(_DependencyInjectionContainer, cachingService);

            //read the module configuration
            IConfigurationBuilder configbuilder = new ConfigurationBuilder();

            configbuilder.SetBasePath(Path.GetDirectoryName(configFile)).AddJsonFile(configFile);
            IConfigurationRoot configurationRoot = configbuilder.Build();

            configurationRoot.Bind("KraftModuleConfigurationSettings", ModuleSettings);

            ModuleSettings.LoadDefinedObjects(moduleKey, configFile);
        }
示例#4
0
 public NodeTaskExecutor(ITransactionScopeContext transactionScope, KraftModuleConfigurationSettings moduleSettings)
 {
     _TransactionScope = transactionScope ?? throw new ArgumentNullException(nameof(transactionScope));
     _KraftModuleConfigurationSettings = moduleSettings;
 }
示例#5
0
        public static Dictionary <string, string> GetCustomSettings(string loaderName, ELoaderType loaderType, KraftModuleConfigurationSettings moduleSettings, bool isIterator = false)
        {
            LoaderProperties loaderProperties = GetLoaderProperties(loaderName, moduleSettings, loaderType, isIterator);

            if (loaderProperties != null)
            {
                return(loaderProperties.CustomSettings);
            }
            else
            {
                throw new NullReferenceException($"Loader properties for loader:{loaderName} are null (internal Dictionary<string, string> GetCustomSettings(string loaderName, Enumerations.ELoaderType loaderType))");
            }
        }
示例#6
0
        internal static T GetPlugin <T>(string key, DependencyInjectionContainer dependencyInjectionContainer, KraftModuleConfigurationSettings kraftConfigurationSettings, ELoaderType pluginType, bool isIterator = false) where T : class
        {
            LoaderProperties loaderProperties = GetLoaderProperties(key, kraftConfigurationSettings, pluginType, isIterator);

            return(dependencyInjectionContainer.Get(loaderProperties.InterfaceAsType, kraftConfigurationSettings.ModuleName + loaderProperties.ImplementationAsString) as T);
        }
示例#7
0
 public PluginAccessorImp(ITransactionScopeContext transactionScope, KraftModuleConfigurationSettings moduleSettings)
 {
     _TransactionScope = transactionScope;
     _KraftModuleConfigurationSettings = moduleSettings;
 }
示例#8
0
        public async Task <IPluginsSynchronizeContextScoped> GetSynchronizeContextScopedAsync <T>(string contextKey, ELoaderType loaderType, KraftModuleConfigurationSettings moduleConfigSettings, T plugin) where T : IPlugin
        {
            string key = $"{moduleConfigSettings.ModuleName}-{contextKey}";

            IPluginsSynchronizeContextScoped pluginsSynchronizeContextScoped = null;

            if (_PluginsSynchronizeContext.ContainsKey(key))
            {
                if (_PluginsSynchronizeContext.TryGetValue(key, out pluginsSynchronizeContextScoped))
                {
                    return(pluginsSynchronizeContextScoped);
                }
                Logger.LogError("_PluginsSynchronizeContext.TryGetValue(contextKey, out pluginsSynchronizeContextScoped) returned false");
            }
            else
            {
                pluginsSynchronizeContextScoped = await plugin.GetSynchronizeContextScopedAsync();

                pluginsSynchronizeContextScoped.CustomSettings = Utilities.GetCustomSettings(contextKey, loaderType, moduleConfigSettings);
                if (CanCache(pluginsSynchronizeContextScoped.CustomSettings))
                {
                    if (!_PluginsSynchronizeContext.TryAdd(key, pluginsSynchronizeContextScoped))
                    {
                        Logger.LogError("_PluginsSynchronizeContext.TryAdd(contextKey, pluginsSynchronizeContextScoped) returned false");
                    }
                }
            }
            return(pluginsSynchronizeContextScoped);
        }