I am working on a library that simplifies application setup. In fact, library users either decorate their configuration classes with attributes or initialize parameters declaratively in the code. One or more sources could be specified from which one could read / write configuration properties (Accessors) or inherit the default value from the class. For example, the following:
[ConfigurationNamespace(DefaultAccessors = new Type[] { typeof(AppSettingsAccessor) })]
public class ClientConfiguration : Configuration<IClientConfiguration>
{
[ConfigurationItem(Accessors = new Type[] {
typeof((RegistryAccessor))
})]
public bool BypassCertificateVerification { get; set; }
}
will be equivalent
var config = new Configuration<IClientConfiguration>();
config.SetDefaultAccessors(new[] { typeof(AppSettingsAccessor) });
config.SetPropertyAccessors(
property: x => x.BypassCertificateVerification,
accessors: new[] { typeof(RegistryAccessor) }
);
(AppSettings, ,.ini .. ..). , . , IoC . [] , - .
(, -, Activator.CreateInstance), - / ? , / -, . , MVC SignalR . 100% ? , factory , .
, , ( Type IConfigurationAccessor factory ).