/// <summary> /// Register default configuration parameters /// </summary> /// <param name="services"></param> /// <param name="action"></param> public static IServiceCollection AddFastDFSClientDefaultOption(this IServiceCollection services, Action <FastDfsSChemeOptions> action) { var option = new FastDfsSChemeOptions(); action.Invoke(option); return(AddFastDFSClientDefaultOption(services, option)); }
/// <summary> /// Register default configuration parameters /// </summary> /// <param name="action">Default parameter configuration method</param> public static void AddFastDFSClientDefaultOption(Action <FastDfsSChemeOptions> action) { var options = new FastDfsSChemeOptions(); action.Invoke(options); DefaultOptionManagement.DefaultOption = options; }
/// <summary> /// Create a configuration object from a configuration file /// </summary> /// <param name="parent">Parent object</param> /// <param name="configContext">Profile context</param> /// <param name="section">Configuration node</param> /// <returns>configuration object</returns> public object Create(object parent, object configContext, XmlNode section) { var options = new FastDfsSChemeOptions(); FormatFromConfig(options, section); var AuthSection = section.SelectSingleNode(DefaultAuthoriteNode); if (AuthSection != null) { if (!Enum.TryParse(AuthSection.Attributes["Type"]?.Value, out AuthoritionType type)) { throw new Exception(UnKnownAuthoriteType); } options.AuthoritionComponent = AuthoritionComponentFactory.CreateAuthoritionComponent(type, AuthSection); } return(options); }
/// <summary> /// Create a configuration object from a configuration file /// </summary> /// <param name="section">Configuration node</param> /// <returns>configuration object</returns> internal static FastDfsSChemeOptions Create(IConfigurationSection section) { var options = new FastDfsSChemeOptions(); FormatFromConfig(options, section); var AuthSection = section.GetSection(DefaultAuthoriteNode); if (AuthSection != null) { if (!Enum.TryParse(AuthSection.GetSection("Type")?.Value, out AuthoritionType type)) { throw new Exception(UnKnownAuthoriteType); } options.AuthoritionComponent = AuthoritionComponentFactory.CreateAuthoritionComponent(type, AuthSection); } return(options); }
private static IServiceCollection AddFastDFSClientDefaultOption(IServiceCollection services, FastDfsSChemeOptions option) { services.AddScoped <IFastDFSService, FastDFSService>(); DefaultOptionManagement.DefaultOption = option; return(services); }