/// <summary> /// Bind the configuration to the a new <see cref="HookOptions"/>, if <see cref="fromSection"/> /// is set to true, the options will be bound from a section of the configuration. /// </summary> /// <param name="configuration">The configuration.</param> /// <param name="fromSection">Determine whether it should be bound from a section or not.</param> /// <returns></returns> public HookOptionsBuilder AddConfiguration(IConfiguration configuration, bool fromSection = false) { if (fromSection) { configuration = configuration.GetSection(nameof(HookOptions)); } var options = new HookOptions(); configuration.Bind(options); _settings = options; return(this); }
public static InjectOptions AsInjectOptions(this HookOptions opt) => new InjectOptions(opt.RedirectionPort, opt.RedirectedIps);
public static bool HasValidInjectOptions(this HookOptions opt) => opt.RedirectionPort != default && opt.RedirectedIps != null && opt.RedirectedIps.Any();