コード例 #1
0
        public UpdateBabySitterCommandTests()
        {
            var provider = ServiceProviderFactory.Create();

            _context = provider.GetService <DatabaseContext>();
            _command = new UpdateBabySitterCommand(_context, new SitterValidator());
        }
コード例 #2
0
        public EndShiftCommandTests()
        {
            var provider = ServiceProviderFactory.Create();

            _context = provider.GetService <DatabaseContext>();
            _command = new EndShiftCommand(_context, new ShiftValidator());
        }
コード例 #3
0
        /// <summary>
        /// Configures the services.
        /// </summary>
        /// <param name="services">The services.</param>
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            // Add MVC and API controllers resolvers.
            services.AddMvc()
            .AddJsonOptions(options =>
            {
                options.SerializerSettings.NullValueHandling = NullValueHandling.Ignore;
                options.SerializerSettings.Converters.Add(new StringEnumConverter());
            });

            // Add data protection. Isolate the application from other applications.
            services.AddDataProtection();

            services.Configure <FormOptions>(option =>
            {
                option.MultipartBodyLengthLimit = 10485760; // 1024 * 1024 * 10; 10 MB
            });

            // Reporting API versions will return the headers "api-supported-versions" and "api-deprecated-versions".
            services.AddApiVersioning(sa =>
            {
                sa.ReportApiVersions = true;
                sa.DefaultApiVersion = new ApiVersion(1, 0);
            });

            // Add DB connection.
            services.AddDbContext <CoreApiContext>(options =>
                                                   options.UseSqlite(Configuration.GetConnectionString("ComparerConnection")));

            // DI framework factory.
            return(ServiceProviderFactory.Create(services));
        }
コード例 #4
0
        public GetBabySitterShiftByIdQueryTests()
        {
            var provider = ServiceProviderFactory.Create();

            _context = provider.GetService <DatabaseContext>();
            _query   = new GetBabySitterShiftByIdQuery(_context);
        }
コード例 #5
0
ファイル: Program.cs プロジェクト: bglogos/FileSort
        /// <summary>
        /// Defines the entry point of the application.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            // Setup DI.
            IServiceProvider serviceProvider = ServiceProviderFactory.Create(GetServices());

            App application = serviceProvider.GetService <App>();

            application.Run(args);
        }
コード例 #6
0
        /// <summary>
        /// 以dto的形式调用服务
        /// </summary>
        /// <param name="serviceName"></param>
        /// <param name="fillArg"></param>
        /// <returns></returns>
        public static DTObject Invoke(string serviceName, Action <DTObject> fillArg)
        {
            var arg = DTObject.CreateReusable();

            if (fillArg != null)
            {
                fillArg(arg);
            }
            ServiceRequest request  = new ServiceRequest(serviceName, DTObject.Empty, arg);
            var            provider = ServiceProviderFactory.Create(request);

            return(provider.Invoke(request));
        }
コード例 #7
0
 private void InvokeTestRun(TestRun testRun, TestRunExecutionContext context, TestRunResult result,
                            ITestRunLogger logger)
 {
     context.TestRun         = testRun;
     context.ServiceProvider = ServiceProviderFactory.Create();
     OnBeforeTestRun(context);
     try
     {
         int stepNumber = 1;
         foreach (ITestRunStep testRunStep in testRun.Steps)
         {
             context.StepNumber = stepNumber++;
             InvokeStep(testRunStep, context, result, logger);
         }
     }
     finally
     {
         context.Step = null;
         var disposableServiceProvider = context.ServiceProvider as IDisposable;
         disposableServiceProvider?.Dispose();
         OnAfterTestRun(context);
     }
 }
コード例 #8
0
 public object CachedProvider() => ServiceProviderFactory.Create <IConvertible, ICloneable, IComparable>(Value, Value, Value);