/// <summary> /// Adds a <see cref="CustomParser"/> to the collection of parsers for detecting the current tenant's canonical name /// from a custom function. /// </summary> /// <typeparam name="TTenant">The type representing a tenant.</typeparam> /// <typeparam name="TKey">The type of the primary key for a tenant.</typeparam> /// <param name="builder">Builder to add the <see cref="CustomParser"/> to.</param> /// <param name="parser">Func that returns the tenant's canonical name from the current request.</param> /// <returns><paramref name="parsers"/> for fluent API.</returns> public static TenancyBuilder <TTenant, TKey> AddCustomParser <TTenant, TKey>(this TenancyBuilder <TTenant, TKey> builder, Func <HttpContext, string> parser) where TTenant : class, ITenanted <TKey> where TKey : IEquatable <TKey> { return(builder.AddCustomParser(httpContext => Task.FromResult(parser(httpContext)))); }
/// <summary> /// Adds a <see cref="CustomParser"/> to the collection of parsers for detecting the current tenant's canonical name /// from a custom function. /// </summary> /// <typeparam name="TTenant">The type representing a tenant.</typeparam> /// <typeparam name="TKey">The type of the primary key for a tenant.</typeparam> /// <param name="builder">Builder to add the <see cref="CustomParser"/> to.</param> /// <param name="parser">Func that returns the tenant's canonical name from the current request.</param> /// <returns><paramref name="parsers"/> for fluent API.</returns> public static TenancyBuilder <TTenant, TKey> AddCustomParser <TTenant, TKey>(this TenancyBuilder <TTenant, TKey> builder, Func <HttpContext, string> parser) where TTenant : class where TKey : IEquatable <TKey> { return(builder.AddCustomParser(httpContext => new ValueTask <string>(parser(httpContext)))); }