// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { StartupIoc.ConfigureServices(services, Configuration); var key = Encoding.ASCII.GetBytes(Settings.Secret); services.AddAuthentication(x => { x.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; x.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(x => { x.RequireHttpsMetadata = false; x.SaveToken = true; x.TokenValidationParameters = new TokenValidationParameters { ValidateIssuerSigningKey = true, IssuerSigningKey = new SymmetricSecurityKey(key), ValidateIssuer = false, ValidateAudience = false }; }); services.AddCors(options => { options.AddPolicy(name: AllowSpecificOrigins, builder => { builder.AllowAnyOrigin(); builder.AllowAnyHeader(); builder.AllowAnyMethod(); }); }); services.AddControllers(); }
static void Main(string[] args) { //if you want to include in the data base var builder = new ConfigurationBuilder().SetBasePath(GetBasePath()) .AddJsonFile("appsettings.json", optional: false); IConfiguration configuration = builder.Build(); var serviceCollection = new ServiceCollection(); //setup our DI StartupIoc.ConfigureServices(serviceCollection, configuration); //do the actual work here var boardService = serviceCollection.BuildServiceProvider().GetService <IBoardRepository>(); var addService = serviceCollection.BuildServiceProvider().GetService <AddBoard>(); //the game without connection with database var game = Game.Models.Game.CreateNewGame(); game.Start(); Thread.Sleep(60000); System.Console.ReadKey(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { StartupIoc.ConfigureServices(services, Configuration["ConnectionString"]); services.AddControllers(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { StartupIoc.ConfigureServices(services, Configuration); services.AddControllersWithViews(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { // services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddMvc(); StartupIoc.ConfigureService(services, Configuration); }