Ejemplo n.º 1
0
        private static Task Main(string[] args)
        {
            var serviceProvider = DiConfiguration.Configure();
            var instance        = serviceProvider.GetService <AppInstance>();

            return(instance.Start());
        }
Ejemplo n.º 2
0
        public IServiceProvider ConfigureServices(IServiceCollection services)
        {
            var configuration = new ConfigurationBuilder()
                                .SetBasePath(Directory.GetCurrentDirectory())
                                .AddJsonFile("config.json")
                                .Build();

            var signingKey = GetKey(configuration["key"]);

            services.AddMvc(options =>
            {
                options.Filters.Add(new UserFilter());
            });

            services
            .AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
            .AddJwtBearer(o =>
            {
                o.RequireHttpsMetadata      = false;
                o.SaveToken                 = false;
                o.TokenValidationParameters = GetTokenValidationParameters(signingKey);
            });

            services.AddCors();
            var container = DiConfiguration.CreateContainer(services);

            return(container.GetInstance <IServiceProvider>());
        }
Ejemplo n.º 3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddCors(options =>
            {
                options.AddPolicy("AllowAPIClient",
                                  builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod()
                    .AllowCredentials();
                });

                options.AddPolicy("AllowHubClient",
                                  builder =>
                {
                    builder.WithOrigins("http://localhost:4200")
                    .AllowAnyHeader()
                    .AllowAnyMethod()
                    .AllowCredentials();
                });
            });
            services.AddAuthentication()
            .AddGoogle(options =>
            {
                options.ClientId     = "687824117544-nvc2uojbm14hc330gl8qh3lsrtl3tc4a.apps.googleusercontent.com";
                options.ClientSecret = "ugBBsDjYS-Rz20RVlx9r7Blo";
            });
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            RegisterAuth(services);
            RegisterIdentity(services);
            RegisterAutoMapperProfiles(services);

            DiConfiguration.Register(services);

            // Register SignalR
            services.AddSignalR();
            services.AddScoped <IAuthEmailSenderUtil, AuthEmailSenderUtil>();
        }
Ejemplo n.º 4
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.Configure <CookiePolicyOptions>(options =>
            {
                // This lambda determines whether user consent for non-essential cookies is needed for a given request.
                options.CheckConsentNeeded    = context => true;
                options.MinimumSameSitePolicy = SameSiteMode.None;
            });

            services.AddCors(options =>
            {
                options.AddPolicy("AllowAPIClient",
                                  builder =>
                {
                    builder.AllowAnyOrigin()
                    .AllowAnyHeader()
                    .AllowAnyMethod()
                    .AllowCredentials();
                });

                options.AddPolicy("AllowHubClient",
                                  builder =>
                {
                    builder.WithOrigins("http://localhost:4200")
                    .AllowAnyHeader()
                    .AllowAnyMethod()
                    .AllowCredentials();
                });
            });

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

            RegisterAuth(services);
            RegisterIdentity(services);
            RegisterAutoMapperProfiles(services);

            DiConfiguration.Register(services);

            // Register SignalR
            services.AddSignalR();
        }
Ejemplo n.º 5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddCors(o =>
            {
                o.AddPolicy("Everything", p =>
                {
                    p.AllowAnyHeader()
                    .AllowAnyMethod()
                    .AllowAnyOrigin();
                });
            });

            // Set up database context
            services.AddDbContext <ApplicationDbContext>(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            // Set up dependency injections
            DiConfiguration.SetUp(services);

            // Add SignalR
            services.AddSignalR();

            // Set up Mvc
            services.AddMvc();
        }
Ejemplo n.º 6
0
 public void Setup()
 {
     config = new DiConfiguration();
 }
Ejemplo n.º 7
0
 protected void Application_Start()
 {
     GlobalConfiguration.Configure(WebApiConfig.Register);
     DiConfiguration.Configure();
 }
Ejemplo n.º 8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();

            DiConfiguration.Configure(services, Configuration);
        }