public virtual void Initialize(IConfigFactory <CosmosDbConfig> configFactory)
        {
            try
            {
                var config   = configFactory.GetConfig();
                var key      = config.MasterKey;
                var endpoint = config.Endpoint;
                DatabaseId          = config.DatabaseId;
                DefaultCollectionId = string.IsNullOrWhiteSpace(config.DefaultCollectionId) ? DatabaseId : config.DefaultCollectionId;

                Client = new DocumentClient(new Uri(endpoint), key, new ConnectionPolicy
                {
                    EnableEndpointDiscovery = false
                });
                Client.OpenAsync();

                CreateDatabaseIfNotExistsAsync().Wait();
                CreateCollectionIfNotExistsAsync(DefaultCollectionId).Wait();
            }
            catch (AggregateException ex)
            {
                TriggerCriticalExceptonEvent(ex.InnerException);
                throw;
            }
            catch (Exception ex)
            {
                TriggerCriticalExceptonEvent(ex);
                throw;
            }
        }
        public static void AddFluentMaps(this IConfigFactory <IGlassMap> mapsConfigFactory, params string[] assemblyFilters)
        {
            Log.Info($"Glass.Mapper Fluent Mapping loading assemblies by filter {string.Join(",", assemblyFilters)}", new object());
            Assembly[] assemblies = GetAssembliesByFilter(assemblyFilters);

            AddFluentMaps(mapsConfigFactory, assemblies);
        }
        public static void AddMaps(IConfigFactory <IGlassMap> mapsConfigFactory)
        {
            // Add maps here
            // mapsConfigFactory.Add(() => new SeoMap());

            mapsConfigFactory.Add(() => new IArticleMap());
        }
        public static void AddFluentMaps(this IConfigFactory <IGlassMap> mapsConfigFactory, params Assembly[] assemblies)
        {
            Log.Info($"Glass.Mapper Fluent Mapping starting!", new object());

            assemblies.ToList().ForEach(assembly =>
            {
                if (assembly.GetReferencedAssemblies().Any(refAssembly => refAssembly.Name.Equals("Glass.Mapper", StringComparison.InvariantCultureIgnoreCase)))
                {
                    Log.Info($"Fluent Mapping Load: {assembly.FullName}", new object());
                    var mappings = assembly.GetTypes().Where(x => typeof(IGlassMap).IsAssignableFrom(x));

                    foreach (var map in mappings)
                    {
                        mapsConfigFactory.Add(() => Activator.CreateInstance(map) as IGlassMap);
                        Log.Info($"Fluent Mapping Loaded: {map.FullName}", new object());
                    }
                }
                else
                {
                    Log.Info($"Skipping {assembly.FullName} it has no Glass.Mapper reference at all.", new object());
                }
            });

            Log.Info($"Glass.Mapper Fluent Mapping completed!", new object());
        }
        public SoftwareRepositoryConfig(IConfigFactory configFactory, dynamic config)
        {
            try
            {
                _configs = new List<IMiningSoftwareConfig>();

                if (config == null)
                {
                    Valid = false;
                    return;
                }

                foreach (var entry in config.miner)
                {
                    _configs.Add(configFactory.GetMiningSoftwareConfig(entry));
                }

                Valid = true;
            }
            catch (Exception e)
            {
                Valid = false;
                Log.Logger.ForContext<SoftwareRepositoryConfig>().Error(e, "Error loading software manager configuration");
            }
        }
示例#6
0
        /// <summary>
        /// Initializes a new instance of <see cref="Registry"/>.
        /// </summary>
        /// <param name="settings">Configuration settings for registry initialization.</param>
        /// <param name="stepFactory">A factory to create steps from settings.</param>
        /// <param name="processorFactory">A factory to create processors from settings.</param>
        /// <param name="policyFactory">A factory to create http client policies from settings.</param>
        /// <param name="clientFactory">A factory to create http client configurations from settings.</param>
        /// <param name="logger">The <see cref="ILogger"/> instance to use for logging.</param>
        /// <param name="loggerFactory">The <see cref="ILoggerFactory"/> instance to use for initializing loggers for created objects.</param>
        public Registry(IRegistrySettings settings,
                        IConfigFactory <IStep> stepFactory,
                        IConfigFactory <IProcessor> processorFactory,
                        IConfigFactory <IAsyncPolicy <HttpResponseMessage> > policyFactory,
                        IConfigFactory <ClientConfig> clientFactory, ILogger <Registry> logger,
                        ILoggerFactory loggerFactory)
        {
            _   = settings ?? throw new ArgumentNullException(nameof(settings));
            _   = stepFactory ?? throw new ArgumentNullException(nameof(stepFactory));
            _   = processorFactory ?? throw new ArgumentNullException(nameof(processorFactory));
            _   = policyFactory ?? throw new ArgumentNullException(nameof(policyFactory));
            _   = clientFactory ?? throw new ArgumentNullException(nameof(clientFactory));
            log = logger ?? throw new ArgumentNullException(nameof(logger));
            _   = loggerFactory ?? throw new ArgumentNullException(nameof(loggerFactory));

            InitializeFromSettings(settings, ProcessorsSection, out processors, (s) => processorFactory.Create(s));
            InitializeFromSettings(settings, StepsSection, out steps, (s) => stepFactory.Create(s));
            InitializeFromSettings(settings, PoliciesSection, out policies, (s) => policyFactory.Create(s));
            InitializeFromSettings(settings, ClientsSection, out clients, (s) => clientFactory.Create(s));

            foreach (var policy in policies)
            {
                log.LogDebug("{Policy} added from {Setting}", policy.Value?.GetType()?.Name, policy.Key);
                PolicyRegistry.Add(policy.Key, policy.Value);
            }

            simpleClientFactory = new SimpleHttpClientFactory(clients, loggerFactory.CreateLogger <SimpleHttpClientFactory>());
        }
示例#7
0
        public static void AddMaps(IConfigFactory <IGlassMap> mapsConfigFactory)
        {
            string binPath = System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, "bin");

            foreach (string dll in Directory.GetFiles(binPath, "SitecoreDev*.dll", SearchOption.AllDirectories))
            {
                try
                {
                    Assembly loadedAssembly = Assembly.LoadFile(dll);

                    Type glassmapType = typeof(IGlassMap);
                    var  maps         = loadedAssembly.GetTypes().Where(x => glassmapType.IsAssignableFrom(x));

                    if (maps != null)
                    {
                        foreach (var map in maps)
                        {
                            mapsConfigFactory.Add(() => Activator.CreateInstance(map) as IGlassMap);
                        }
                    }
                }
                catch (FileLoadException loadEx)
                { } // The Assembly has already been loaded.
                catch (BadImageFormatException imgEx)
                { } // If a BadImageFormatException exception is thrown, the file is not an assembly.
            }
        }
示例#8
0
        public SoftwareRepositoryConfig(IConfigFactory configFactory, dynamic config)
        {
            try
            {
                _configs = new List <IMiningSoftwareConfig>();

                if (config == null)
                {
                    Valid = false;
                    return;
                }

                foreach (var entry in config.miner)
                {
                    _configs.Add(configFactory.GetMiningSoftwareConfig(entry));
                }

                Valid = true;
            }
            catch (Exception e)
            {
                Valid = false;
                Log.Logger.ForContext <SoftwareRepositoryConfig>().Error(e, "Error loading software manager configuration");
            }
        }
        public static void AddMaps(IConfigFactory <IGlassMap> mapsConfigFactory)
        {
            var factory = new SitecoreSettingsFactory();
            //Load referenced assemblies
            var assemblies = Assembly.GetExecutingAssembly().GetReferencedAssemblies().Select(Assembly.Load).ToList();

            //load possible standalone assemblies
            assemblies.AddRange(AppDomain.CurrentDomain.GetAssemblies()
                                .Where(assembly => assembly.GetCustomAttributes(typeof(IgnitionAutomapAttribute)).Any())
                                .Where(a => !assemblies.Contains(a))
                                .Select(a => Assembly.Load(a.FullName)));
            var manyTypes     = assemblies.SelectMany(s => s.GetTypes());
            var filteredTypes = manyTypes.Where(p => typeof(IGlassMap).IsAssignableFrom(p) && !p.IsAbstract && !p.IsInterface)
                                .ToList();

            filteredTypes.ForEach(a => mapsConfigFactory.Add(() =>
            {
                var mapper  = (IGlassMap)Activator.CreateInstance(a);
                var setting = mapper as IGlassSettingsConsumer;
                if (setting != null)
                {
                    setting.SettingsFactory = factory;
                }
                return((IGlassMap)setting ?? mapper);
            }));
        }
        public static void AddMaps(IConfigFactory <IGlassMap> mapsConfigFactory)
        {
            var pipelineArgs = new AddMapsPipelineArgs {
                MapsConfigFactory = mapsConfigFactory
            };

            AddMapsPipeline.Run(pipelineArgs);
        }
示例#11
0
 public static void AddMaps(IConfigFactory <IGlassMap> mapsConfigFactory)
 {
     // Add maps here
     mapsConfigFactory.Add(() => new TaxonomyMap());
     //mapsConfigFactory.Add(() => new ListableConfig());
     //mapsConfigFactory.Add(() => new ArticleMap());
     //mapsConfigFactory.Add(() => new ScripConfig());
 }
示例#12
0
        public BanConfigTests()
        {
            var kernel = TinyIoCContainer.Current;

            new Bootstrapper(kernel);
            _configFactory    = kernel.Resolve <IConfigFactory>();
            _jsonConfigReader = _configFactory.GetJsonConfigReader();
        }
        protected virtual void TryFinalise <T>(IConfigFactory <T> factory)
        {
            var finalisable = factory as AbstractFinalisedConfigFactory <T>;

            if (finalisable != null)
            {
                finalisable.Finalise();
            }
        }
示例#14
0
        public ConfigManager(IConfigFactory configFactory, IJsonConfigReader jsonConfigReader)
        {
            _configFactory    = configFactory;
            _jsonConfigReader = jsonConfigReader;

            PoolConfigs = new List <IPoolConfig>(); // list of pool configurations.

            ReadGlobalConfig();                     // read the global config.
        }
示例#15
0
 public ConfigCache(
     DocumentFormat.OpenXml.Wordprocessing.Numbering numbering,
     DocumentFormat.OpenXml.Wordprocessing.Styles styles,
     IConfigFactory numberingConfigFac)
 {
     _numbering = numbering;
     _styles    = styles;
     _numberingConfigFactory = numberingConfigFac;
 }
 public CommandLineArgsConfigProvider(
     IEnumerable <ICommandLineEndpointConfigProvider> commandLineEndpointConfigProviders,
     IRouteConfigFactory routeConfigFactory,
     IConfigFactory configFactory)
 {
     _commandLineEndpointConfigProviders = commandLineEndpointConfigProviders;
     _routeConfigFactory = routeConfigFactory;
     _configFactory      = configFactory;
 }
示例#17
0
        /// <summary>
        /// Загружает все конфигурации в коллекцию
        /// </summary>
        private void LoadConfig()
        {
            if (!_rsPath.ContainsKey(ResourceType.Config.ToString()))
            {
                throw new ApplicationException($"В файле {RESOURCE_PATH_FILE} отсутствуют настройки для файлов конфигураций {ResourceType.Config.ToString()}");
            }

            _configFactory = new ConfigFactory(_rsPath[ResourceType.Config.ToString()]);
        }
        public void Register(string namespaceName, IConfigFactory factory)
        {
            if (m_instances.ContainsKey(namespaceName))
            {
                logger.Warn(string.Format("ConfigFactory({0}) is overridden by {1}!", namespaceName, factory.GetType()));
            }

            m_instances[namespaceName] = factory;
        }
示例#19
0
        public static void AddFluentMaps(this IConfigFactory <IGlassMap> mapsConfigFactory, params Assembly[] assemblies)
        {
            var mappings = GetTypes.GetTypesImplementing <IGlassMap>(assemblies);

            foreach (var map in mappings)
            {
                mapsConfigFactory.Add(() => Activator.CreateInstance(map) as IGlassMap);
            }
        }
        public void Register(string namespaceName, IConfigFactory factory)
        {
            if (_instances.ContainsKey(namespaceName))
            {
                Logger().Warn($"ConfigFactory({namespaceName}) is overridden by {factory.GetType()}!");
            }

            _instances[namespaceName] = factory;
        }
示例#21
0
        /// <summary>
        /// 加载配置,使用自定义配置工厂
        /// </summary>
        /// <param name="configFactory">配置工厂</param>
        public static void LoadConfig(IConfigFactory configFactory)
        {
            if (configFactory == null)
            {
                throw new ArgumentNullException(nameof(configFactory));
            }
            IClientConfig clientConfig = configFactory.CreateConfig();

            LoadConfig(clientConfig);
        }
示例#22
0
        public ConfigManager(IConfigFactory configFactory, IJsonConfigReader jsonConfigReader, ILogManager logManager)
        {
            _configFactory    = configFactory;
            _jsonConfigReader = jsonConfigReader;
            _logManager       = logManager;
            _logger           = Log.ForContext <ConfigManager>();

            LoadGlobalConfig();          // read the global config.
            LoadSoftwareManagerConfig(); // load software manager config file.
            LoadDefaultPoolConfig();     // load default pool config if exists.
            LoadPoolConfigs();           // load the per-pool config files.
        }
示例#23
0
        public ConfigManager(IConfigFactory configFactory)
        {
            _configFactory = configFactory;

            _globalConfigData = JsonConfigReader.Read(GlobalConfigFilename); // read the global config data.
            PoolConfigs = new List<IPoolConfig>();
            _coinConfigs =  new Dictionary<string, ICoinConfig>();

            LogConfig = new LogConfig(_globalConfigData.logging);
            WebServerConfig = new WebServerConfig(_globalConfigData.website);

            // TODO: implement metrics config.
        }
示例#24
0
        public ConfigManager(IConfigFactory configFactory, IJsonConfigReader jsonConfigReader, ILogManager logManager)
        {
            _configFactory = configFactory;
            _jsonConfigReader = jsonConfigReader;
            _logManager = logManager;
            _logger = Log.ForContext<ConfigManager>();

            LoadGlobalConfig(); // read the global config.
            LoadMarketsManagerConfig();
            LoadSoftwareManagerConfig(); // load software manager config file.
            LoadDefaultPoolConfig(); // load default pool config if exists.
            LoadPoolConfigs(); // load the per-pool config files.
        }
        public static void AddMaps(IConfigFactory <IGlassMap> mapsConfigFactory)
        {
            // Add maps here
            var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName.IndexOf("Helixbase", StringComparison.OrdinalIgnoreCase) >= 0);

            var glassmapType = typeof(IGlassMap);

            foreach (var assembly in assemblies)
            {
                var mappings = assembly.GetTypes().Where(x => glassmapType.IsAssignableFrom(x));

                foreach (var map in mappings)
                {
                    mapsConfigFactory.Add(() => Activator.CreateInstance(map) as IGlassMap);
                }
            }
        }
示例#26
0
        public IConfigFactory GetFactory(string namespaceName)
        {
            IConfigFactory factory = _registry.GetFactory(namespaceName);

            if (factory != null)
            {
                return(factory);
            }

            if (_factories.TryGetValue(namespaceName, out factory))
            {
                return(factory);
            }

            _factories[namespaceName] = factory;

            return(factory);
        }
 public static void AddMaps(IConfigFactory <IGlassMap> mapsConfigFactory)
 {
     // Add maps here
     // mapsConfigFactory.Add(() => new SeoMap());
     mapsConfigFactory.Add(() => new BreadcrumbMap());
     mapsConfigFactory.Add(() => new CanonicalMap());
     mapsConfigFactory.Add(() => new FacebookMetadataMap());
     mapsConfigFactory.Add(() => new GooglePlusMetadataMap());
     mapsConfigFactory.Add(() => new MetadataMap());
     mapsConfigFactory.Add(() => new NavigationMap());
     mapsConfigFactory.Add(() => new ScriptsMap());
     mapsConfigFactory.Add(() => new SearchMap());
     mapsConfigFactory.Add(() => new SitemapMap());
     mapsConfigFactory.Add(() => new TwitterMetadataMap());
     mapsConfigFactory.Add(() => new SocialSettingsMap());
     mapsConfigFactory.Add(() => new PageMetadataMap());
     mapsConfigFactory.Add(() => new GlassBaseMap());
     mapsConfigFactory.Add(() => new GlassBaseIMap());
 }
示例#28
0
 public static void AddMaps(IConfigFactory<IGlassMap> mapsConfigFactory)
 {
     // Add maps here
     // mapsConfigFactory.Add(() => new SeoMap());
     mapsConfigFactory.Add(() => new BreadcrumbMap());
     mapsConfigFactory.Add(() => new CanonicalMap());
     mapsConfigFactory.Add(() => new FacebookMetadataMap());
     mapsConfigFactory.Add(() => new GooglePlusMetadataMap());
     mapsConfigFactory.Add(() => new MetadataMap());
     mapsConfigFactory.Add(() => new NavigationMap());
     mapsConfigFactory.Add(() => new ScriptsMap());
     mapsConfigFactory.Add(() => new SearchMap());
     mapsConfigFactory.Add(() => new SitemapMap());
     mapsConfigFactory.Add(() => new TwitterMetadataMap());
     mapsConfigFactory.Add(() => new SocialSettingsMap());
     mapsConfigFactory.Add(() => new PageMetadataMap());
     mapsConfigFactory.Add(() => new GlassBaseMap());
     mapsConfigFactory.Add(() => new GlassBaseIMap());
 }
示例#29
0
        public IConfigFactory GetFactory(String namespaceName)
        {
            // step 1: check hacked factory
            IConfigFactory factory = m_registry.GetFactory(namespaceName);

            if (factory != null)
            {
                return(factory);
            }

            // step 2: check cache
            m_factories.TryGetValue(namespaceName, out factory);

            if (factory != null)
            {
                return(factory);
            }

            // step 3: check declared config factory
            try
            {
                factory = ComponentLocator.Lookup <IConfigFactory>(namespaceName);
            }
            catch (Exception)
            {
                // ignore it
            }

            // step 4: check default config factory
            if (factory == null)
            {
                factory = ComponentLocator.Lookup <IConfigFactory>();
            }

            m_factories[namespaceName] = factory;

            // factory should not be null
            return(factory);
        }
        public static void AddMaps(IConfigFactory <IGlassMap> mapsConfigFactory)
        {
            var configurationAssemblies = AppDomain.CurrentDomain.GetAssemblies().Where(x => x.FullName.EndsWith("Model", StringComparison.OrdinalIgnoreCase)).ToList();

            if (configurationAssemblies != null)
            {
                Type glassmapType = typeof(IGlassMap);

                foreach (var assembly in configurationAssemblies)
                {
                    var maps = assembly.GetTypes().Where(x => glassmapType.IsAssignableFrom(x));

                    if (maps != null)
                    {
                        foreach (var map in maps)
                        {
                            mapsConfigFactory.Add(() => Activator.CreateInstance(map) as IGlassMap);
                        }
                    }
                }
            }
        }
示例#31
0
        public IConfig GetConfig(string namespaceName)
        {
            IConfig config;

            _configs.TryGetValue(namespaceName, out config);

            if (config == null)
            {
                lock (this)
                {
                    _configs.TryGetValue(namespaceName, out config);

                    if (config == null)
                    {
                        IConfigFactory factory = _factoryManager.GetFactory(namespaceName);

                        config = factory.Create(namespaceName);
                        _configs[namespaceName] = config;
                    }
                }
            }

            return(config);
        }
示例#32
0
 public ConfigManager(IConfigFactory configFactory, IConfigHolder configHolder)
 {
     this.configFactory = configFactory;
     this.configHolder  = configHolder;
 }
 public static void AddMaps(IConfigFactory<IGlassMap> mapsConfigFactory)
 {
     // Add maps here
     // mapsConfigFactory.Add(() => new SeoMap());
 }
示例#34
0
        public static void AddFluentMaps(this IConfigFactory <IGlassMap> mapsConfigFactory, params string[] assemblyFilters)
        {
            var assemblies = GetAssemblies.GetByFilter(assemblyFilters);

            AddFluentMaps(mapsConfigFactory, assemblies);
        }
 public static void AddMaps(IConfigFactory <IGlassMap> mapsConfigFactory)
 {
     // Add maps here
     // mapsConfigFactory.Add(() => new SeoMap());
     mapsConfigFactory.AddFluentMaps("Helixbase.Foundation.*", "Helixbase.Feature.*");
 }