示例#1
0
 /// <summary>
 /// Adds configuration to registry
 /// </summary>
 /// <param name="registration">Configuration registration to be added</param>
 /// <returns>returns true if successful or false if registration already in registry</returns>
 public bool AddRegistration(ConfigurationRegistration registration)
 {
     if (collection.ContainsKey(registration.ConfigType))
     {
         return(false);
     }
     collection.Add(registration.ConfigType, registration);
     return(true);
 }
 /// <summary>
 /// Adds ConfigInstance type to ConfigServer client registry
 /// </summary>
 /// <typeparam name="TConfig">ConfigInstance type to be added to registry</typeparam>
 /// <param name="source">Current ConfigServer client builder</param>
 /// <returns>ConfigServer client builder for further configuration</returns>
 public static ConfigServerClientBuilder WithCollectionConfig <TConfig>(this ConfigServerClientBuilder source) where TConfig : class, new()
 {
     source.ConfigurationRegistry.AddRegistration(ConfigurationRegistration.BuildCollection <TConfig>());
     return(source);
 }
 /// <summary>
 /// Adds ConfigInstance type to ConfigServer client registry
 /// </summary>
 /// <typeparam name="TConfig">ConfigInstance type to be added to registry</typeparam>
 /// <param name="source">Current ConfigServer client builder</param>
 /// <returns>ConfigServer client builder for further configuration</returns>
 public static ConfigServerClientBuilder WithConfig <TConfig>(this ConfigServerClientBuilder source) where TConfig : class, new()
 {
     source.ServiceCollection.Add(ServiceDescriptor.Transient(r => r.GetService <IConfigServerClient>().BuildConfigAsync <TConfig>().Result));
     source.ConfigurationRegistry.AddRegistration(ConfigurationRegistration.Build <TConfig>());
     return(source);
 }
示例#4
0
 /// <summary>
 /// Tries to get Registration for type
 /// </summary>
 /// <param name="type">Type of config being requested</param>
 /// <param name="value">ConfigurationRegistration for type</param>
 /// <returns>True if found, false if not</returns>
 public bool TryGet(Type type, out ConfigurationRegistration value) => collection.TryGetValue(type, out value);
示例#5
0
 /// <summary>
 /// Constructs Registration for config and adds it to the registry
 /// </summary>
 /// <typeparam name="TConfig">Type of configuration to be added to the registry</typeparam>
 /// <returns>returns true if successful or false if registration already in registry</returns>
 public bool BuildAndAddRegistration <TConfig>() where TConfig : class, new()
 {
     return(AddRegistration(ConfigurationRegistration.Build <TConfig>()));
 }