コード例 #1
0
ファイル: Bindings.cs プロジェクト: goofybryan/ZarDevs
 public static void ConfigurePerformanceTest(this IDependencyBuilder builder)
 {
     builder.Bind <PerformanceMethodTest>().Resolve <IPerformanceMethodTest>();
     builder.BindFunction((ctx) => PerformanceMethodTest.Method()).Resolve <IPerformanceMethodResultTest>();
     builder.Bind <PerformanceConstructParamTest>().Resolve <IPerformanceConstructParam1Test>();
     builder.Bind <PerformanceConstructParamTest>().Resolve <IPerformanceConstructParam2Test>();
     builder.Bind <PerformanceConstructParamTest>().Resolve <IPerformanceConstructParam3Test>();
     builder.Bind <PerformanceConstructTest>().Resolve <IPerformanceConstructTest>();
     builder.Bind <PerformanceSingletonTest>().Resolve <IPerformanceSingletonTest>().InSingletonScope();
     builder.BindInstance(new PerformanceInstanceTest()).Resolve <IPerformanceInstanceTest>();
 }
コード例 #2
0
ファイル: HttpConfigure.cs プロジェクト: goofybryan/ZarDevs
        /// <summary>
        /// Configure the API HTTP factory for the solution.
        /// </summary>
        /// <param name="builder">The dependency builder.</param>
        /// <param name="handlerFactory">Specify the handler factory.</param>
        /// <returns></returns>
        public static IDependencyBuilder ConfigureHttp(this IDependencyBuilder builder, IApiHttpHandlerFactory handlerFactory)
        {
            if (handlerFactory is null)
            {
                throw new ArgumentNullException(nameof(handlerFactory));
            }

            ApiHttpFactory.Instance = new ApiHttpFactory(new System.Net.Http.HttpClient(), handlerFactory, new ApiHttpRequestHandlerBindingMap());

            builder.BindInstance(ApiHttpFactory.Instance).Resolve <IApiHttpFactory>();
            builder.BindFunction((ctx) => ApiHttpFactory.Instance.NewClient(ctx.Info.Key)).Resolve <IApiHttpClient>().InTransientScope();

            return(builder);
        }