Esempio n. 1
0
        public ConfigurationsService()
        {
            configs = new List <StoredConfig>();

            foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies())
            {
                var OnLoadConfigAssemblies = asm.GetTypes()
                                             .Where(type => !type.IsInterface && !type.IsAbstract)
                                             .Where(type => typeof(IConfigurationBase).IsAssignableFrom(type))
                                             .Where(type => type.GetCustomAttribute <OnLoadConfiguration>() != null);

                if (OnLoadConfigAssemblies.Count() > 0)
                {
                    foreach (Type type in OnLoadConfigAssemblies)
                    {
                        // Get the constructor and create an instance of Config
                        ConstructorInfo    constructor = type.GetConstructor(Type.EmptyTypes);
                        IConfigurationBase config      = constructor.Invoke(new object[] { }) as IConfigurationBase;

                        configs.Add(new StoredConfig
                        {
                            Namespace = type.Namespace,
                            Name      = type.Name,
                            Config    = config
                        });
                    }
                }
            }

            LoadConfigs();
        }
 protected FileHistoryTarget(IJ4JLogger <FileHistoryTarget> logger, IConfigurationBase config)
 {
     Logger        = logger ?? throw new NullReferenceException(nameof(logger));
     Configuration = config ?? throw new NullReferenceException(nameof(config));
 }