// 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.ConfigureDatabase(Configuration); services.AddMvc(options => { options.ModelBinderProviders.Insert(0, new CustomBinderProvider()); }) .SetCompatibilityVersion(CompatibilityVersion.Version_2_2); services.AddLocalServices(); services.ConfigureAuthentication(); MapperInitializer.Initialize(); // This code fixes a bug in providing current directory //https://stackoverflow.com/questions/54508735/directory-getcurrentdirectory-doesnt-return-the-correct-directory CurrentDirectoryHelper.SetCurrentDirectory(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); GlobalConfiguration.Configure(WebApiConfig.Register); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); MapperInitializer.Initialize(); }
public ShellViewModel(IEventAggregator eventAggregator, IRegionManager regionManager, INavigationService navigationService) : base("Shell") { _eventAggregator = eventAggregator; _regionManager = regionManager; _regionManager.RegisterViewWithRegion(Helpers.Constants.MainRegion, typeof(LoginView)); _eventAggregator.GetEvent <CloseMenuEvent>().Subscribe(MenuStateChanged); MapperInitializer.Initialize(); }
public void Configuration(IAppBuilder app) { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); MapperInitializer.Initialize(); InitializeWindsorContainer(app); ConfigureAuth(app); ClientDataTypeModelValidatorProvider.ResourceClassKey = "ErrorMessages"; DefaultModelBinder.ResourceClassKey = "ErrorMessages"; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //注入数据库上下文 services.AddDbContext <ApplicationDbContext>(options => options.UseMySql(Configuration.GetConnectionString("DefaultConnection"), b => b.MigrationsAssembly("Zal.Beauty.WebApp"))); // Add framework services. services.AddMvc(); //权限注入 services.AddAuthorization(options => { Type type = typeof(PermissionKeys); FieldInfo[] fieldInfos = type.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy); foreach (FieldInfo fi in fieldInfos) { var permissionKey = fi.GetValue(null).ToString(); options.AddPolicy(permissionKey, policy => policy.RequireClaim(ClaimTypes.AuthorizationDecision, permissionKey)); } }); //注入manager ManagerRegistrar.RegistManager(services); //初始化映射配置 MapperInitializer.Initialize(); }
public ProductCatalogueServiceTests() { var x = MapperInitializer.Initialize(); }
public ClientsService(IClientsRepository clientsRepository) { _clientsRepository = clientsRepository; _mapper = MapperInitializer.Initialize(); }
public UserFixture() { MapperInitializer.Initialize(); DependencyInitializer.Initialize(); }
public HiveManagementServiceTests() { MapperInitializer.Initialize(); }
static HiveServiceAutoFixtureTests() { MapperInitializer.Initialize(); }
public HiveServiceTests() { var x = MapperInitializer.Initialize(); }
static void Initialize() { MapperInitializer.Initialize(); DependencyInitializer.Initialize(); }
public ServiceFixture() { MapperInitializer.Initialize(); DependencyInitializer.Initialize(); }
public UserServiceTests() { MapperInitializer.Initialize(); }
public static void Initialize(IServiceCollection services) { MapperInitializer.Initialize(services); }
public ProductCategoryServiceTests() { var x = MapperInitializer.Initialize(); }
public void ConfigureServices(IServiceCollection services) { //global level handle status code services.AddControllers(action => { action.Filters.Add(new ProducesResponseTypeAttribute(StatusCodes.Status404NotFound)); action.Filters.Add(new ProducesResponseTypeAttribute(StatusCodes.Status200OK)); action.Filters.Add(new ProducesResponseTypeAttribute(StatusCodes.Status500InternalServerError)); action.Filters.Add(new ProducesResponseTypeAttribute(StatusCodes.Status401Unauthorized)); action.ReturnHttpNotAcceptable = true; action.Filters.Add(new AuthorizeFilter()); }).AddNewtonsoftJson() .AddXmlSerializerFormatters(); services.AddOptions();//Add functionality to inject IOptions<T> SwaggerUIAPIBootstrap.Initialize(services, _env); MapperInitializer.Initialize(services); //services.AddAuthentication("Basic") // .AddScheme<AuthenticationSchemeOptions, BasicAuthenticationHandler>("Basic", null); //services.AddAuthentication(options => //{ // options.DefaultAuthenticateScheme = "API Key"; // options.DefaultChallengeScheme = "API Key"; //}); services.AddAuthentication("oauth") .AddScheme <AuthenticationSchemeOptions, ApiKeyAuthenticationHandler>("oauth", null); services.AddSwaggerGen(action => { action.SwaggerDoc("CustomerApi", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "Customer", Version = "1", Description = "Through this API can access customers information", Contact = new Microsoft.OpenApi.Models.OpenApiContact() { Name = "Abrar Ahmad Ansari", Email = "*****@*****.**", Url = new Uri("https://www.google.com"), }, License = new Microsoft.OpenApi.Models.OpenApiLicense() { Name = "Abrar Ahmad Ansari", Url = new Uri("https://www.google.com") } }); action.SwaggerDoc("SupplierApi", new Microsoft.OpenApi.Models.OpenApiInfo { Title = "Supplier", Version = "1", Description = "Through this API can access supplier information", Contact = new Microsoft.OpenApi.Models.OpenApiContact() { Name = "Abrar Ahmad Ansari", Email = "*****@*****.**", Url = new Uri("https://www.google.com"), }, License = new Microsoft.OpenApi.Models.OpenApiLicense() { Name = "Abrar Ahmad Ansari", Url = new Uri("https://www.google.com") } }); var xmlCommentFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlCommentPath = Path.Combine(AppContext.BaseDirectory, xmlCommentFile); action.IncludeXmlComments(xmlCommentPath); //authorization //http basic authentication //action.AddSecurityDefinition("basicAuth", new Microsoft.OpenApi.Models.OpenApiSecurityScheme() //{ // Type = Microsoft.OpenApi.Models.SecuritySchemeType.Http, // Scheme = "basic", // In = ParameterLocation.Header,//optional // Description = "input yourname and password to access the api" //}); //action.AddSecurityRequirement(new Microsoft.OpenApi.Models.OpenApiSecurityRequirement() //{ // { // new OpenApiSecurityScheme // { // Reference = new OpenApiReference // { // Type = ReferenceType.SecurityScheme, // Id = "basicAuth" // } // },new List<string>() // } //}); // api key action.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { Description = "Standard Authorization header using the Bearer scheme. Example: \"bearer {token}\"", In = ParameterLocation.Header, Name = "X-Api-Key", Type = SecuritySchemeType.ApiKey, Scheme = "Bearer" }); action.AddSecurityRequirement(new Microsoft.OpenApi.Models.OpenApiSecurityRequirement() { { new OpenApiSecurityScheme { Reference = new OpenApiReference { Type = ReferenceType.SecurityScheme, Id = "Bearer" }, Name = "Bearer", In = ParameterLocation.Header }, new List <string>() } }); }); }