Пример #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseCors(AllowAllOriginsPolicy);
            }

            app.UseMvc();

            EntityFrameworkConfig.Configure(app, env);
        }
Пример #2
0
        public static EntityFrameworkConfig ReadConfiguration(string file = "config/EntityFramework.config")
        {
            var config       = new ConfigHelper();
            var entityconfig = new EntityFrameworkConfig();

            try
            {
                entityconfig = config.Reader <EntityFrameworkConfig>(file);
                switch (entityconfig.BaseType.ToLower())
                {
                case "mssql":
                    entityconfig.SqlType = EntityFrameworkType.MsSql;
                    break;

                case "mysql":
                    entityconfig.SqlType = EntityFrameworkType.MySql;
                    break;

                case "oracle":
                    entityconfig.SqlType = EntityFrameworkType.Oracle;
                    break;

                case "sqlite":
                    entityconfig.SqlType = EntityFrameworkType.Sqlite;
                    break;

                case "":
                    entityconfig.SqlType = EntityFrameworkType.Null;
                    break;

                default:
                    entityconfig.SqlType = EntityFrameworkType.MsSql;
                    break;
                }
                if (string.IsNullOrEmpty(entityconfig.Connect))
                {
                    entityconfig.SqlType = EntityFrameworkType.Null;
                }
            }
            catch (Exception exception)
            {
                entityconfig.SqlType = EntityFrameworkType.Null;
                LogHelper.Log(exception);
            }
            return(entityconfig);
            //finally
            //{
            //    Config.IsCache = false;
            //    IsCacheError = true;
            //}
        }
Пример #3
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            CorsConfig.Add(ref services, Configuration);
            APIControllersConfig.Add(ref services, Configuration);
            EntityFrameworkConfig.Add(ref services, Configuration);
            AuthenticationConfig.Add(ref services, Configuration);
            var mapper = AutoMapperConfig.Add(ref services, Configuration);

            APIVersioningConfig.Add(ref services, Configuration);
            SwaggerConfig.Add(ref services, Configuration);
            DependencyInjectionConfig.Add(ref services, Configuration, ref mapper);
            HealthChecksConfig.Add(ref services, Configuration);
            SignalRConfig.Add(ref services, Configuration);
        }
Пример #4
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            EntityFrameworkConfig.AddConfigurationContext(services, _configuration);

            services.ConfigureApplicationServices();
            services.ConfigureSwaggerServices();

            services.AddCors(options =>
            {
                options.AddPolicy(CORS_POLICY_NAME, policy =>
                {
                    policy.AllowAnyHeader().AllowAnyMethod().WithOrigins(ORIGINS_CORS_POLICY);
                });
            });
        }
Пример #5
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            //register services
            services.AddMvc();
            MappingConfig.ConfigureServices(services);
            RepositoryConfig.ConfigureServices(services);
            EntityFrameworkConfig.ConfigureServices(services, Configuration);

            services.AddCors(o => o.AddPolicy(AllowAllOriginsPolicy, builder =>
            {
                builder.AllowAnyOrigin()
                .AllowAnyMethod()
                .AllowAnyHeader();
            }));

            //use default json contract resolver due to prevent lowercase transformation
            services.AddMvc().AddJsonOptions(p => p.SerializerSettings.ContractResolver = new DefaultContractResolver());
        }
Пример #6
0
 public static void ApplicationStart()
 {
     try
     {
         StructureMapConfig.RegisterStructureMap();
         MvcConfig.RegisterMvc();
         //EntityFrameworkProfilerConfig.RegisterEntityFrameworkProfiler();
         AreaRegistration.RegisterAllAreas();
         RouteConfig.RegisterRoutes(RouteTable.Routes);
         BundleConfig.RegisterBundles(BundleTable.Bundles);
         FilterConfig.RegisterFilters(GlobalFilters.Filters);
         //RazorGeneratorConfig.RegisterRazorGenerator();
         EntityFrameworkConfig.RegisterEntityFramework();
         AutoMapperConfig.RegisterAutoMapper();
         StartupConfig.Configuration();
         Configuration();
     }
     catch
     {
         // سبب ری استارت برنامه و آغاز مجدد آن با درخواست بعدی می‌شود
         HttpRuntime.UnloadAppDomain();
         throw;
     }
 }
 public DbMasterSlaveCommandInterceptor(EntityFrameworkConfig config)
 {
     this._config            = config;
     _masterConnectionString = ConfigurationManager.ConnectionStrings[config.MasterConnName].ConnectionString;
     LogManager.GetLogger(Typename).Debug("DbMasterSlaveCommandInterceptor()");
 }
 // This method gets called by the runtime. Use this method to add services to the container.
 public void ConfigureServices(IServiceCollection services)
 {
     // Add framework services.
     services.AddMvc();
     services.AddDbContext <FormBuilderDbContext>(t => EntityFrameworkConfig.Get(Configuration, t));
 }
 public override void Initialize()
 {
     Config = Context.Plugin.GetConfig <EntityFrameworkConfig>();
 }
 public DbMasterSlaveCommandInterceptor(EntityFrameworkConfig config)
 {
     this._config = config;
     LogManager.GetLogger(Typename).Debug("DbMasterSlaveCommandInterceptor()");
 }
 protected void Application_Start()
 {
     RouteConfig.RegisterRoutes(RouteTable.Routes);
     EntityFrameworkConfig.Config();
 }