void Application_Start(object sender, EventArgs e) { IocConfig.RegisterDependencies(); IocConfig.RegisterApiDependencies(); DataBaseStartUp(); MapperInitialization.CreateMaps(); AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); }
static void Main(string[] args) { // 初始化映射关系 MapperInitialization.InitMapper(); FirstMapper mapper = new FirstMapper(); mapper.MapperTest(); SecondMapper secondMapper = new SecondMapper(); secondMapper.MapBookStore(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { MapperInitialization.Initialize(); services.AddDbContext <DemandDbContext>(option => option.UseSqlServer(Configuration.GetConnectionString("DefaultConnection"))); services.AddScoped <IUserService, UserService>(); services.AddScoped <IMenuService, MenuService>(); services.AddScoped <IRoleService, RoleService>(); services.AddScoped <ICustomerService, CustomerService>(); services.AddScoped <ISoftwareVersionService, SoftwareVersionService>(); services.AddScoped <IDemandService, DemandService>(); services.AddScoped <IWxUserService, WxUserService>(); //services.AddMvc(options => //{ // var policy = new AuthorizationPolicyBuilder() // .RequireAuthenticatedUser() // .Build(); // options.Filters.Add(new AuthorizeFilter(policy)); //}).AddJsonOptions(options => //{ // //options.SerializerSettings.DateFormatString = "yyyy年MM月dd日"; //}); services.AddMvc(); services.AddSession(); //services.AddAuthentication(options => //{ // options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; //}).AddCookie(options => //{ //}); services.AddAuthentication(options => { options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme; }).AddCookie().AddJwtBearer(options => { options.TokenValidationParameters = new TokenValidationParameters { NameClaimType = JwtClaimTypes.Name, RoleClaimType = JwtClaimTypes.Role, ValidIssuer = "zyc", ValidAudience = "all", IssuerSigningKey = new SymmetricSecurityKey(Encoding.ASCII.GetBytes(Configuration["jwtkey"])) }; }); }
public MainWindow() { InitializeComponent(); MapperInitialization.Init(); }
public InitFixture() { MapperInitialization.Initialize(Assembly.GetAssembly(typeof(Startup))); }