Esempio n. 1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            _owinConfiguration = new OwinConfiguration();
            Configuration.GetSection("OwinConfiguration").Bind(_owinConfiguration);

            var connectionString = Configuration.GetConnectionString("DefaultConnection");

            services.AddDbContext <AppDb>(options => { options.UseSqlServer(connectionString); });

            services.AddTransient <IQuestionAnswerRepository, QuestionAnswerRepository>();
            services.AddTransient <IQuestionAnswerService, QuestionAnswerService>();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            services.AddCors(options =>
            {
                options.AddPolicy("default", policy =>
                {
                    policy
                    .WithOrigins(_owinConfiguration.WithOrigins)
                    .AllowAnyHeader()
                    .AllowAnyMethod()
                    .AllowCredentials();
                });
            });
        }
Esempio n. 2
0
        public async Task StartAsync(string configSectionName, Func <OwinConfiguration, Task> configure = null)
        {
            var serverPath      = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, configSectionName);
            var serverDirectory = new DirectoryInfo(serverPath);

            serverDirectory.Refresh();
            if (serverDirectory.Exists)
            {
                serverDirectory.Delete(true);
            }

            var configuration        = new OwinConfiguration();
            var configurationManager = new OwinConfigurationManager();
            await configurationManager.Initialize(configuration, configSectionName);

#pragma warning disable 612
            await configurationManager.FindAndProcessConfigurationHooks(configuration);

#pragma warning restore 612

            if (configure != null)
            {
                await configure(configuration);
            }

            var baseUri = configuration.BaseUri;
            _subscriptionTrackingService = configuration.SubscriptionTrackingService;
            _messageQueueingService      = configuration.MessageQueueingService;

            var transportServiceOptions = new HttpTransportServiceOptions(baseUri, _messageQueueingService, _subscriptionTrackingService)
            {
                DiagnosticService = configuration.DiagnosticService,
                Endpoints         = configuration.Endpoints,
                MessageJournal    = configuration.MessageJournal,
                BypassTransportLocalDestination = configuration.BypassTransportLocalDestination
            };

            _transportService = new HttpTransportService(transportServiceOptions);

            var bus = new Bus(configuration, baseUri, _transportService, _messageQueueingService);
            _transportService.MessageReceived += (sender, args) => bus.HandleMessage(args.Message, args.Principal);

            await _transportService.Init();

            await bus.Init();

            Bus = bus;

            _middleware = new PlatibusMiddleware(configuration, bus, _transportService);
            _webapp     = WebApp.Start(baseUri.ToString(), app => app.UsePlatibusMiddleware(_middleware));
        }
Esempio n. 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            _owinConfiguration = new OwinConfiguration();
            Configuration.GetSection("OwinConfiguration").Bind(_owinConfiguration);
            _identityConfiguration = new IdentityConfiguration();
            Configuration.GetSection("IdentityConfiguration").Bind(_identityConfiguration);

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            //Cors policies
            services.AddCors(options =>
            {
                options.AddPolicy("default", policy =>
                {
                    policy.WithOrigins("https://localhost:4200")
                    .AllowAnyHeader()
                    .AllowAnyMethod()
                    .AllowCredentials();
                });
            });

            //Prevent looping reference
            services.AddMvc().AddJsonOptions(options =>
            {
                options.SerializerSettings.ReferenceLoopHandling      = ReferenceLoopHandling.Ignore;
                options.SerializerSettings.PreserveReferencesHandling = PreserveReferencesHandling.None;
            });

            //Database setup
            var connectionString = Configuration.GetConnectionString("DefaultConnection");

            services.AddDbContext <BefordingTestContext>(opt =>
                                                         opt.UseSqlServer(connectionString));

            services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme)
            .AddIdentityServerAuthentication(options =>
            {
                options.Authority = _identityConfiguration.Authority;
                options.ApiName   = _identityConfiguration.ApiName;
            });

            //Adding to container so services can be used with Dependency Injection
            services.AddScoped <IUserInfoService, UserInfoService>();
            services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>();
            services.AddTransient <IProfileRepository, ProfileRepository>();
            services.AddTransient <IPatientRepository, PatientRepository>();
            services.AddTransient <ILogRepository, LogRepository>();
        }
Esempio n. 4
0
 public void Configuration(IAppBuilder app)
 {
     OwinConfiguration.Configuartion(app);
 }