Ejemplo n.º 1
0
 /// <summary>
 /// 启用制定路由策略
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="tenantParam"></param>
 /// <returns></returns>
 public static MultiTenantBuilder WithRouteStrategy(
     this MultiTenantBuilder builder,
     string tenantParam)
 {
     if (string.IsNullOrWhiteSpace(tenantParam))
     {
         throw new ArgumentException("\"tenantParam\" 不能为空", nameof(tenantParam));
     }
     return(builder.WithStrategy <RouteStrategy>(ServiceLifetime.Singleton, new object[] { tenantParam }));
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 委托策略
 /// </summary>
 /// <param name="builder"></param>
 /// <param name="doStrategy">委托函数</param>
 /// <returns></returns>
 public static MultiTenantBuilder WithDelegateStrategy(
     this MultiTenantBuilder builder,
     Func <object, Task <string> > doStrategy)
 {
     if (doStrategy == null)
     {
         throw new ArgumentNullException(nameof(doStrategy));
     }
     return(builder.WithStrategy <DelegateStrategy>(ServiceLifetime.Singleton, new object[] { doStrategy }));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Adds and configures a HostStrategy to the application.
        /// </summary>
        /// <param name="template">The template for determining the tenant identifier in the host.</param>
        /// <returns>The same MultiTenantBuilder passed into the method.</returns>
        public static MultiTenantBuilder WithHostStrategy(
            this MultiTenantBuilder builder,
            string template)
        {
            if (string.IsNullOrWhiteSpace(template))
            {
                throw new ArgumentException("Invalid value for \"template\"", nameof(template));
            }

            return(builder.WithStrategy <HostStrategy>(ServiceLifetime.Singleton, new object[] { template }));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 静态策略
        /// </summary>
        /// <param name="builder"></param>
        /// <param name="identifier">策略标识</param>
        /// <returns></returns>
        public static MultiTenantBuilder WithStaticStrategy(
            this MultiTenantBuilder builder,
            string identifier)
        {
            if (string.IsNullOrWhiteSpace(identifier))
            {
                throw new ArgumentException("Invalid value for \"identifier\"", nameof(identifier));
            }

            return(builder.WithStrategy <StaticStrategy>(ServiceLifetime.Singleton, new object[] { identifier }));;
        }
Ejemplo n.º 5
0
 public static MultiTenantBuilder WithBasePathStrategy(this MultiTenantBuilder builder)
 => builder.WithStrategy <BasePathStrategy>(ServiceLifetime.Singleton);