// 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("CorsPolicy", builder => { builder .WithOrigins("http://greencode.vn:52701", "https://my8-dev.s3-ap-southeast-1.amazonaws.com") .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials(); })); services.AddSignalR().AddJsonProtocol(opts => { opts.PayloadSerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); }); services.Configure <ClientConfig>(Configuration.GetSection("ClientConfig")); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddMvc().AddJsonOptions(opts => { opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); }); services.Addmy8Authentication(Configuration, "my8.Client"); services.AddDistributedMemoryCache(); services.AddSession(); MapConfig.Config(services); _configServices(services); }
protected void Application_Start() { log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(Server.MapPath("~/Config/log4net.config"))); // MEF配置 MefConfig.RegisterMefDependencyResolver(); AreaRegistration.RegisterAllAreas(); // WebApi配置 WebApiConfig.Register(GlobalConfiguration.Configuration); // 全局过滤器注册 FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); // 路由注册 RouteConfig.RegisterRoutes(RouteTable.Routes); //初始化映射 MapConfig.Config(); AutoMapperConfig.Config(); FormattersConfig.Config(); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { //services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) // .AddCookie(option=> { // option.ExpireTimeSpan = TimeSpan.FromDays(30); // option.SlidingExpiration = true; // option.Cookie.Name = "my8"; // option.LoginPath = "/Account/Login"; // }); services.AddCors(o => o.AddPolicy("CorsPolicy", builder => { builder .AllowAnyMethod() .AllowAnyHeader() .AllowAnyOrigin(); })); services.AddSignalR().AddJsonProtocol(opts => { opts.PayloadSerializerSettings.ContractResolver = new DefaultContractResolver(); }); services.Configure <ClientConfig>(Configuration.GetSection("ClientConfig")); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.AddMvc().AddJsonOptions(opts => { opts.SerializerSettings.ContractResolver = new DefaultContractResolver(); }); services.Addmy8Authentication(Configuration, "my8.Client"); services.AddDistributedMemoryCache(); services.AddSession(); MapConfig.Config(services); _configServices(services); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); MapConfig.Config(); }
protected T GetInstance <T>() { if (container == null) { RegisterMefDependencyResolver(); MapConfig.Config(); } return(container.GetExport <T>()); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <MvcOptions>(options => { options.Filters.Add(new CorsAuthorizationFilterFactory("AllowSpecificOrigin")); }); services.AddCors(options => { options.AddPolicy("AllowSpecificOrigin", builder => builder.WithOrigins("http://localhost:14021").AllowAnyHeader() .AllowAnyMethod().AllowCredentials()); }); services.AddSignalR(); services.Configure <MongoConnection>(Configuration.GetSection("MongoConnection")); services.Configure <Neo4jConnection>(Configuration.GetSection("Neo4jConnection")); services.Configure <SqlServerConnection>(Configuration.GetSection("SqlServerConnection")); //services.AddMvc(); services.AddMvc().AddJsonOptions(opts => { opts.SerializerSettings.ContractResolver = new DefaultContractResolver(); }); MapConfig.Config(services); services.AddScoped <NotificationHub>(); //SmartCenter services.AddScoped <IFeedSmart, FeedSmart>(); services.AddScoped <IClientAuthorizeBusiness, ClientAuthorizeBusiness>(); //Business services.AddScoped <IPageBusiness, PageBusiness>(); services.AddScoped <IPersonBusiness, PersonBusiness>(); services.AddScoped <ICommunityBusiness, CommunityBusiness>(); services.AddScoped <IStatusPostBusiness, StatusPostBusiness>(); services.AddScoped <IPostBroadcastPersonBusiness, PostBroadcastPersonBusiness>(); services.AddScoped <IJobFunctionBusiness, JobFunctionBusiness>(); services.AddScoped <ISkillBusiness, SkillBusiness>(); services.AddScoped <ILocationBusiness, LocationBusiness>(); services.AddScoped <IProvinceBusiness, ProvinceBusiness>(); services.AddScoped <IDistrictBusiness, DistrictBusiness>(); services.AddScoped <IDegreeBusiness, DegreeBusiness>(); services.AddScoped <IJobPostBusiness, JobPostBusiness>(); services.AddScoped <ICommentBusiness, CommentBusiness>(); services.AddScoped <IReplyCommentBusiness, ReplyCommentBusiness>(); services.AddScoped <IFeedLikeBusiness, FeedLikeBusiness>(); services.AddScoped <ILastPostBroadCastBusiness, LastPostBroadCastBusiness>(); services.AddScoped <INotificationBusiness, NotificationBusiness>(); services.AddScoped <IExperienceBusiness, ExperienceBusiness>(); //<AppendBusinessDI> //Mongo services.AddSingleton <MongoI.IStatusPostRepository, MongoR.StatusPostRepository>(); services.AddSingleton <MongoI.ICommentRepository, MongoR.CommentRepository>(); services.AddSingleton <MongoI.IJobPostRepository, MongoR.JobPostRepository>(); services.AddSingleton <MongoI.IPersonRepository, MongoR.PersonRepository>(); services.AddSingleton <MongoI.IJobPostRepository, MongoR.JobPostRepository>(); services.AddSingleton <MongoI.IJobPostRepository, MongoR.JobPostRepository>(); services.AddSingleton <MongoI.IUniversityRepository, MongoR.UniversityRepository>(); services.AddSingleton <MongoI.IDeletedPostRepository, MongoR.DeletedPostRepository>(); services.AddSingleton <MongoI.ICommunityRepository, MongoR.CommunityRepository>(); services.AddSingleton <MongoI.IPageRepository, MongoR.PageRepository>(); services.AddSingleton <MongoI.IPostBroadcastPersonRepository, MongoR.PostBroadcastPersonRepository>(); services.AddSingleton <MongoI.IJobFunctionRepository, MongoR.JobFunctionRepository>(); services.AddSingleton <MongoI.ISkillRepository, MongoR.SkillRepository>(); services.AddSingleton <MongoI.ILocationRepository, MongoR.LocationRepository>(); services.AddSingleton <MongoI.IProvinceRepository, MongoR.ProvinceRepository>(); services.AddSingleton <MongoI.IDistrictRepository, MongoR.DistrictRepository>(); services.AddSingleton <MongoI.IDegreeRepository, MongoR.DegreeRepository>(); services.AddSingleton <MongoI.IReplyCommentRepository, MongoR.ReplyCommentRepository>(); services.AddSingleton <MongoI.IFeedLikeRepository, MongoR.FeedLikeRepository>(); services.AddSingleton <MongoI.ILastPostBroadCastRepository, MongoR.LastPostBroadCastRepository>(); services.AddSingleton <MongoI.INotificationRepository, MongoR.NotificationRepository>(); services.AddSingleton <MongoI.ICommentNotifyRepository, MongoR.CommentNotifyRepository>(); services.AddSingleton <MongoI.INotificationRepository, MongoR.NotificationRepository>(); services.AddSingleton <MongoI.IExperienceRepository, MongoR.ExperienceRepository>(); //AppendMongoDI //Neo services.AddSingleton <NeoI.IPageRepository, NeoR.PageRepository>(); services.AddSingleton <NeoI.IPersonRepository, NeoR.PersonRepository>(); services.AddSingleton <NeoI.ICommunityRepository, NeoR.CommunityRepository>(); //AppendNeoDI //Sql services.AddSingleton <SqlI.IPersonRepository, SqlR.PersonRepository>(); services.AddSingleton <SqlI.IClientAuthorizeRepository, SqlR.ClientAuthorizeRepository>(); //AppendSqlDI }
public static void ClassInit() { RegisterMefDependencyResolver(); MapConfig.Config(); AutoMapperConfig.Config(); }