コード例 #1
0
 protected void Application_Start()
 {
     DependencyResolverConfig.Initialize();
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     AreaRegistration.RegisterAllAreas();
     RouteConfig.RegisterRoutes(RouteTable.Routes);
 }
コード例 #2
0
    protected void Application_Start()
    {
        // Enables and configures selected Kentico ASP.NET MVC integration features
        ApplicationConfig.RegisterFeatures(ApplicationBuilder.Current);

        // Registers routes including system routes for enabled features
        RouteConfig.RegisterRoutes(RouteTable.Routes);

        // Custom Bundles
        Bundles.RegisterBundles(BundleTable.Bundles);

        // Clear cache on application start.
        CacheHelper.ClearCache();

        #region "AutoFac Cache and other dependency injections"

        // Register AutoFac Items
        var builder = new ContainerBuilder();

        // Register Dependencies for Cache
        DependencyResolverConfig.Register(builder);

        // Register AutoMapper
        AutoMapper.Resolver.AutoMapperDependencyResolverConfig.Register(builder);

        // Set Autofac Dependency resolver to the builder
        DependencyResolver.SetResolver(new AutofacDependencyResolver(builder.Build()));

        #endregion

        RegisterPageTemplateFilters();

        // SECURITY: Remove MVC Response powered by
        MvcHandler.DisableMvcResponseHeader = true;
    }
コード例 #3
0
ファイル: Application_Start.cs プロジェクト: techieshop/RP
        public static void Initialize()
        {
            DependencyResolverConfig.RegisterType(new WebTypeResolver());

            DependencyResolver.SetResolver(new UnityDependencyResolver(DependencyResolverConfig.Container));

            RouteConfig.RegisterRoute(new DefaultRouteResolver());
            FilterConfig.RegisterFilter(new DefaultFilterResolver());
            BundleConfig.RegisterBundle(new DefaultBundleResolver());
            MappingConfig.RegisterMapping(new DefaultProfile());

            DataAnnotationsModelValidatorProvider.AddImplicitRequiredAttributeForValueTypes = false;

            foreach (ModelValidatorProvider provider in ModelValidatorProviders.Providers)
            {
                if (provider is ClientDataTypeModelValidatorProvider)
                {
                    ModelValidatorProviders.Providers.Remove(provider);
                    break;
                }
            }

            ModelMetadataProviders.Current = new RPModelMetadataProvider();

            ModelBinders.Binders.Add(typeof(double), new DoubleModelBinder());
            ModelBinders.Binders.Add(typeof(ICollection <int>), new IntCollectionModelBinder());
            ModelBinders.Binders.Add(typeof(KeyValuePair <,>), new KeyValuePairModelBinder());
        }
コード例 #4
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     DependencyResolverConfig.RegisterDependencies();
     GlobalConfiguration.Configure(WebApiConfig.Register);
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
 }
コード例 #5
0
 protected void Application_Start()
 {
     AreaRegistration.RegisterAllAreas();
     FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     BundleConfig.RegisterBundles(BundleTable.Bundles);
     DependencyResolverConfig.RegisterDependencies();
     AutoMapperConfig.RegisterMappings();
 }
コード例 #6
0
        public void Test()
        {
            var configureContainer = DependencyResolverConfig.ConfigureContainer();

            var companyKeyPersonsRetriever = configureContainer.Resolve <ICompanyKeyPersonsRetriever>();

            var keyPersons = companyKeyPersonsRetriever.GetKeyPersons("GOOGL.OQ");

            Assert.IsNotNull(keyPersons);
        }
コード例 #7
0
        public void ConfigureContainer_ResolveICompanyValuationService_ResolvedInnocentCompanyValuationService()
        {
            // Act
            var configureContainer = DependencyResolverConfig.ConfigureContainer();

            var companyValuationService = configureContainer.Resolve <ICompanyValuationService>();

            // Assert
            companyValuationService.Should().BeOfType <CompanyValuationService>();
        }
コード例 #8
0
        public void ConfigureContainer_ResolveCompanyController_Resolved()
        {
            // Act
            var configureContainer = DependencyResolverConfig.ConfigureContainer();

            var valuationController = configureContainer.Resolve <CompanyController>();

            // Arrange
            valuationController.Should().BeOfType <CompanyController>();
        }
コード例 #9
0
        public async Task EvaluatePersonAsync_SuspiciousPerson_SomeResults()
        {
            var configureContainer      = DependencyResolverConfig.ConfigureContainer();
            var personEvaluationService = configureContainer.Resolve <IPersonEvaluationService>();

            var searchEngineResults = await personEvaluationService.EvaluatePersonAsync("Stella Handler", "fraud");

            // Assert
            searchEngineResults.Should().HaveCountGreaterThan(0);
        }
コード例 #10
0
        public async Task EvaluatePersonAsync_InnocentPerson_ZeroResults()
        {
            var configureContainer      = DependencyResolverConfig.ConfigureContainer();
            var personEvaluationService = configureContainer.Resolve <IPersonEvaluationService>();

            var searchEngineResults = await personEvaluationService.EvaluatePersonAsync("Michael Corbat", "money laundering");

            // Assert
            searchEngineResults.Should().HaveCount(0);
        }
コード例 #11
0
        public void ConfigureContainer_ResolveCashedCompanyDataRetriever_Resolved()
        {
            // Act
            var configureContainer = DependencyResolverConfig.ConfigureContainer();

            var cashedCompanyDataRetriever1 = configureContainer.Resolve <ICashedCompanyDataRetriever>();
            var cashedCompanyDataRetriever2 = configureContainer.Resolve <ICashedCompanyDataRetriever>();

            // Assert
            cashedCompanyDataRetriever1.Should().Be(cashedCompanyDataRetriever2);
        }
コード例 #12
0
        public async Task ConfigureContainer_ResolveICompanyValuationService_ResolvedInnocentCompanyValuationService()
        {
            // Act
            var configureContainer = DependencyResolverConfig.ConfigureContainer();

            var companyValuationService = configureContainer.Resolve <IInnocentCompanyValuationService>();
            var companyValuationData    = await companyValuationService.GetCompanyValuationData("citigroup");

            // Assert
            companyValuationData.TotalScore.Should().Be(0);
        }
コード例 #13
0
ファイル: Bootstrapper.cs プロジェクト: SMPhotos/SMPhotos
        public static void Initialize()
        {
            DependencyResolverConfig.RegisterType(
                new WebTypeResolver()
                );

            Mapper.Initialize(config =>
            {
                config.AddProfile(new MappingProfile());
            });
            Mapper.AssertConfigurationIsValid();
        }
コード例 #14
0
        protected void Application_Start()
        {
            ApplicationConfig.RegisterFeatures(ApplicationBuilder.Current);

            var container = DependencyResolverConfig.BuildContainer();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

            WebApiConfig.ConfigureWebApi(container);

            RouteConfig.RegisterRoutes(RouteTable.Routes);

            FilterConfig.RegisterGlobalFilters(ValueProviderFactories.Factories, container);
        }
コード例 #15
0
 public RequestDispatcherTest(ITestOutputHelper testOutputHelper)
 {
     _container = DependencyResolverConfig.StartRegistrations()
                  .CoreDependencies()
                  .FakeDatabases()
                  .FakeSmtpClientWrapper()
                  .FakeApplicationSettings()
                  .TestOutputHelper(testOutputHelper)
                  .EventSubscriberDiagnostics()
                  .CommandHandlerDiagnostics()
                  .QueryHandlerDiagnostics()
                  .SmtpClientDiagnostics()
                  .DbContextDiagnostics()
                  .VerifyContainer();
 }
コード例 #16
0
        public async Task Initialize_TotalScore_IsGreaterThanZero()
        {
            // Arrange
            var configureContainer     = DependencyResolverConfig.ConfigureContainer();
            var valuationInitializer   = configureContainer.Resolve <IValuationInitializer>();
            var cashedValuationService = configureContainer.Resolve <ICashedValuationService>();

            // Act
            valuationInitializer.Initialize();

            var cachedValudationData = await cashedValuationService.GetCachedValudationData("bezeq");

            // Assert
            cachedValudationData.TotalScore.Should().BeGreaterThan(0);
        }
コード例 #17
0
    protected void Application_Start()
    {
        // ADD THE BELOW TO YOUR APPLICATION_START
        #region "AutoFac Cache and other dependency injections"

        // Register AutoFac Items
        var builder = new ContainerBuilder();

        // Register Dependencies for Cache
        DependencyResolverConfig.Register(builder);

        // Set Autofac Dependency resolver to the builder
        DependencyResolver.SetResolver(new AutofacDependencyResolver(builder.Build()));

        #endregion
    }
コード例 #18
0
        static void Main()
        {
            Bootstrapper.Initialize();
            var apiCallerService = DependencyResolverConfig.Resolve <ApiCallerService>();

#if DEBUG
            Console.WriteLine(ServiceConfigManager.ServiceName);
            Console.WriteLine(">> Service is starting... Press any key for exit.");
            apiCallerService.DebugStart();
            Console.ReadKey();
            Console.WriteLine(">> Service is stopping.");
            apiCallerService.Stop();
#else
            ServiceBase.Run(apiCallerService);
#endif
        }
コード例 #19
0
        //[Ignore("Integration")]
        public async Task EvaluateCompany(string companyName)
        {
            var configureContainer = DependencyResolverConfig.ConfigureContainer();

            var companyValuationService = configureContainer.Resolve <ICompanyValuationService>();

            CompanyData companyValuationData = await companyValuationService.GetCompanyValuationData(companyName);

            var serializer = new JsonSerializer {
                Formatting = Formatting.Indented
            };

            using (var file = File.CreateText($@"c:\work\github\kyciti-api\{companyName}.json"))
            {
                serializer.Serialize(file, companyValuationData);
            }
        }
コード例 #20
0
        public static void MakeReports(BackgroundJobInfo jobInfo)
        {
            var resolver = DependencyResolverConfig.GetResolver(true);
            var service  = (IReportingService)resolver.GetService(typeof(IReportingService));

            var fetcher = new EndpointFetcher();

            foreach (var endpoint in jobInfo.Endpoints)
            {
                Task.Run(() =>
                {
                    var report = fetcher.MakeHealthReport(endpoint.Url, endpoint.Id);
                    report.IntervalInMinutes = jobInfo.FetchIntervalInMinutes;
                    service.AddReportSyncroniously(report);
                });
            }
        }
コード例 #21
0
        protected void Application_Start()
        {
            /**
             * Enables and configures selected Kentico ASP.NET MVC integration features
             */
            ApplicationConfig.RegisterFeatures(ApplicationBuilder.Current);

            var container = DependencyResolverConfig.Register();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));

            RouteConfig.RegisterRoutes(RouteTable.Routes, container);

            WebApiConfig.ConfigureWebApi(container);

            BundleConfig.RegisterBundles(BundleTable.Bundles);

            FilterConfig.RegisterGlobalFilters(FilterProviders.Providers, GlobalFilters.Filters, container);
        }
コード例 #22
0
ファイル: Global.asax.cs プロジェクト: ttiamus/CharacterGen
        protected void Application_Start()
        {
            var config = GlobalConfiguration.Configuration;

            var container = DependencyResolverConfig.GetContainer();

            container.RegisterWebApiControllers(config);
            container.Verify();     //Check that everything is registered correctly
            config.DependencyResolver = new SimpleInjectorWebApiDependencyResolver(container);

            AutoMapperConfig.RegisterMappings();

            //config.Formatters.JsonFormatter.SerializerSettings =
            //    new JsonSerializerSettings() { Converters = new List<JsonConverter> { new ObjectIdConverter() } };

            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }
コード例 #23
0
    protected void Application_Start()
    {
        // Register services both CMS and custom
        DependencyInjectionConfig.RegisterDependencies();

        // Enables and configures selected Kentico ASP.NET MVC integration features
        ApplicationConfig.RegisterFeatures(ApplicationBuilder.Current);

        // Registers routes including system routes for enabled features
        RouteConfig.RegisterRoutes(RouteTable.Routes);

        // Custom Bundles
        Bundles.RegisterBundles(BundleTable.Bundles);

        // Clear cache on application start.
        CacheHelper.ClearCache();

        #region "AutoFac Cache and other dependency injections"

        // Register AutoFac Items
        var builder = new ContainerBuilder();

        // Register Dependencies for Cache
        DependencyResolverConfig.Register(builder);

        // Autowire Property Injection for controllers (can't have constructor injection)
        var allControllers = Assembly.GetExecutingAssembly().GetTypes().Where(type => typeof(BaseController).IsAssignableFrom(type));
        foreach (var controller in allControllers)
        {
            builder.RegisterType(controller).PropertiesAutowired();
        }

        // Set Autofac Dependency resolver to the builder
        DependencyResolver.SetResolver(new AutofacDependencyResolver(builder.Build()));

        #endregion

        RegisterPageTemplateFilters();
    }
コード例 #24
0
ファイル: Bootstrapper.cs プロジェクト: BasilKosovan/Varyence
 public static void Initialize()
 {
     DependencyResolverConfig.RegisterType(
         new ApiCallerTypeResolver()
         );
 }
コード例 #25
0
 // MVC Caching
 public void ConfigureContainer(ContainerBuilder builder)
 {
     DependencyResolverConfig.Register(builder, new Assembly[] { typeof(Startup).Assembly });
 }