/// <summary> /// Adds and configures a DelegateStrategy to the application. /// </summary> /// <param name="doStrategy">The delegate implementing the strategy.</returns> public static MultiTenantBuilder <TTenant, TKey> WithDelegateStrategy <TTenant, TKey>(this MultiTenantBuilder <TTenant, TKey> builder, Func <object, Task <TKey> > doStrategy) where TTenant : class, IIdentityTenant <TKey>, new() { if (doStrategy == null) { throw new ArgumentNullException(nameof(doStrategy)); } return(builder.WithStrategy <DelegateStrategy <TKey> >(ServiceLifetime.Singleton, new object[] { doStrategy })); }
/// <summary> /// Adds and configures a HttpHeaderAttrStrategy to the application. /// </summary> /// <param name="httpHeaderAttributeKey">The http request header attribute key for determining the tenant identifier in the http request header attribute.</param> /// <returns>The same MultiTenantBuilder passed into the method.</returns> public static MultiTenantBuilder <TTenant, TKey> WithHeaderAttributeStrategy <TTenant, TKey>(this MultiTenantBuilder <TTenant, TKey> builder, string httpHeaderAttributeKey) where TTenant : class, IIdentityTenant <TKey>, new() { return(builder.WithStrategy <HttpHeaderAttrStrategy <TKey> >(ServiceLifetime.Singleton, httpHeaderAttributeKey)); }
/// <summary> /// Adds and configures a StaticStrategy to the application. /// </summary> /// <param name="identifier">The tenant identifier to use for all tenant resolution.</param> public static MultiTenantBuilder <TTenant, TKey> WithStaticStrategy <TTenant, TKey>(this MultiTenantBuilder <TTenant, TKey> builder, string identifier) where TTenant : class, IIdentityTenant <TKey>, new() { if (string.IsNullOrWhiteSpace(identifier)) { throw new ArgumentException("Invalid value for \"identifier\"", nameof(identifier)); } return(builder.WithStrategy <StaticStrategy <TKey> >(ServiceLifetime.Singleton, new object[] { identifier }));; }
/// <summary> /// Adds and configures a ClaimStrategy to the application. /// </summary> /// <param name="tenantClaimTypeKey">The claim type key for determining the tenant identifier in the claims identity.</param> /// <returns>The same MultiTenantBuilder passed into the method.</returns> public static MultiTenantBuilder <TTenant, TKey> WithClaimStrategy <TTenant, TKey>(this MultiTenantBuilder <TTenant, TKey> builder, string tenantClaimTypeKey) where TTenant : class, IIdentityTenant <TKey>, new() { return(builder.WithStrategy <ClaimStrategy <TKey> >(ServiceLifetime.Singleton, tenantClaimTypeKey)); }