Пример #1
0
        public void Configuration(IAppBuilder app)
        {
            var config = new HttpConfiguration();

            RegisterTelemetryInstrumentationKey();
            StartBackgroundWorker(app);
            EmailTemplatesConfig.Register(AppDomain.CurrentDomain.BaseDirectory);
            SwaggerConfig.Setup(config);
            SerializationIgnoreConfigs.Configure();
            RouteConfig.Register(config);
            WebApiConfig.Register(config);
            FilterConfig.RegisterGlobalWebApiFilters(config.Filters);

            ConfigureAuthMiddleware(app);

            app.UseCors(SetupCorsOptions());
            app.Use <ImageResizerMiddleware>();
            app.Use <MultitenancyMiddleware>();

            var container = IocBootstrapper.Bootstrap(app, ExtractConnString, config);

            config.DependencyResolver     = new AutofacWebApiDependencyResolver(container);
            GlobalHost.DependencyResolver = new Autofac.Integration.SignalR.AutofacDependencyResolver(container);

            ConfigureAuthServer(app, container);

            app.UseAutofacMiddleware(container);
            app.UseAutofacWebApi(config);
            SetupGlobalization(app);
            ConfigureSignalr(app);
            app.UseWebApi(config);

            // InitiateScheduledJobs();
        }
Пример #2
0
        // This code configures Web API. The Startup class is specified as a type
        // parameter in the WebApp.Start method.
        public static void ConfigureApp(IAppBuilder app, IContainer container)
        {
            var version = Assembly.GetExecutingAssembly().GetName().Version;

            app.Properties["host.AppName"] = ConfigurationManager.AppSettings["AppName"];
            app.Properties["host.AppMode"] = ConfigurationManager.AppSettings["ENV"];

            //FIXME: We need a module to load development/production mode so error pages can be turned on/off
            //Better have a global configuration module like Asp.net 5, that looked awesome!
            switch (app.Properties["host.AppMode"].ToString())
            {
            case ("development"):
            case ("mock"):
                app.UseErrorPage();
                break;
            }

            SetupMongoConventions();
            SetupJobTaskExtensions();

            app.UseAutofacMiddleware(container);
            app.Use(typeof(PreflightRequestsHandler));
            app.UseForwardHeaders(options: default(ForwardedHeadersOptions));

            var webApiDependencyResolver = new AutofacWebApiDependencyResolver(container);


            var config = new HttpConfiguration();


            BsonSerializerConfig.Configure();

            // INFO: This is not done either
            ConfigureResourceOAuth(app, container);

            WebApiConfig.Register(config, webApiDependencyResolver);
            config.Filters.Add(new ErrorDocumentFilter());


            app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll);

            app.UseWebApi(config);
            app.UseAutofacWebApi(config);

            EmailTemplatesConfig.Configure();

            //FIXME: Can be a small middleware. No? Alright!
            app.Run(context =>
            {
                context.Response.ContentType = "text/plain";
                return(context.Response.WriteAsync(string.Format($"Welcome to TaskCat '{version}', proudly baked by NerdCats")));
            });
        }
Пример #3
0
        public void TestOneTimeInitializer()
        {
            _stopWatch = Stopwatch.StartNew();
            TestContext.Progress.WriteLine("Started templates compilation");

            Assembly.Load("Shrooms.Constants");
            Assembly.Load("Shrooms.DataTransferObjects");
            Assembly.Load("Shrooms.Domain");

            EmailTemplatesConfig.Register(AppDomain.CurrentDomain.BaseDirectory + @"\..\..\..\..\Main\PresentationLayer\Shrooms.API");

            _stopWatch.Stop();
            TestContext.Progress.WriteLine("Finished templates compilation.");
            TestContext.Progress.WriteLine($"Duration: {_stopWatch.Elapsed}");
        }