Пример #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 }));
 }
Пример #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 }));
 }
Пример #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 }));
        }
Пример #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 }));;
        }
Пример #5
0
 public static MultiTenantBuilder WithBasePathStrategy(this MultiTenantBuilder builder)
 => builder.WithStrategy <BasePathStrategy>(ServiceLifetime.Singleton);