public Startup(IConfiguration configuration) { Configuration = configuration; FastMap.InstanceProperties("FastApiGatewayDb.DataModel", "FastApiGatewayDb.Ui.dll"); FastMap.InstanceTable("FastApiGatewayDb.DataModel", "FastApiGatewayDb.Ui.dll"); FastMap.InstanceMap(); }
protected void Application_Start() { RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); FastMap.InstanceProperties("DataModel.AI", "EMR.Web.dll"); FastMap.InstanceProperties("DataModel.CD", "EMR.Web.dll"); FastMap.InstanceProperties("DataModel.CN", "EMR.Web.dll"); FastMap.InstanceProperties("DataModel.GI", "EMR.Web.dll"); FastMap.InstanceMap(AppEmr.DbConst.EmrDb); }
public void ConfigureServices(IServiceCollection services) { //注册gbk Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); Encoding encoding = Encoding.GetEncoding("GB2312"); //http请求 using (var db = new DataContext("ApiGateway")) { var list = FastRead.Query <ApiGatewayDownParam>(a => a.Protocol != "", a => new { a.Key, a.Url }).ToList <ApiGatewayDownParam>(db); foreach (var item in list) { services.AddHttpClient(item.Key, client => { client.BaseAddress = new Uri(item.Url); }).ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler { ServerCertificateCustomValidationCallback = (message, certificate2, arg3, arg4) => true, AllowAutoRedirect = false, AutomaticDecompression = DecompressionMethods.Deflate | DecompressionMethods.GZip }); } } //压缩 services.AddResponseCompression(); //注入 services.AddTransient <IFastApiGatewayDb, FastApiGatewayDb.FastApiGatewayDb>(); //跨域 services.AddCors(options => { options.AddPolicy("any", builder => { builder.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader(); }); }); //oracle FastMap.InstanceProperties("FastApiGatewayDb.DataModel.Oracle", "FastApiGatewayDb.dll"); FastMap.InstanceTable("FastApiGatewayDb.DataModel.Oracle", "FastApiGatewayDb.dll"); //MySql //FastMap.InstanceProperties("FastApiGatewayDb.DataModel.MySql", "FastApiGatewayDb.dll"); //FastMap.InstanceTable("FastApiGatewayDb.DataModel.MySql", "FastApiGatewayDb.dll"); //SqlServer //FastMap.InstanceProperties("FastApiGatewayDb.DataModel.SqlServer", "FastApiGatewayDb.dll"); //FastMap.InstanceTable("FastApiGatewayDb.DataModel.SqlServer", "FastApiGatewayDb.dll"); }
public static IServiceCollection AddFastData(this IServiceCollection serviceCollection, Action <ConfigData> action) { config = new ConfigData(); action(config); if (!config.IsResource && DataConfig.Get(config.dbKey, null, config.dbFile).CacheType == CacheType.Redis && ServiceContext.Engine.Resolve <IRedisRepository>() == null) { throw new System.Exception("ConfigureServices First add services.AddFastRedis(); Second add services.AddFastData()"); } if (DataConfig.Get(config.dbKey, Assembly.GetCallingAssembly().GetName().Name, config.dbFile).CacheType == CacheType.Redis && ServiceContext.Engine.Resolve <IRedisRepository>() == null) { throw new System.Exception("ConfigureServices First add services.AddFastRedis(); Second add services.AddFastData()"); } serviceCollection.AddSingleton <IFastRepository, FastRepository>(); Assembly.GetCallingAssembly().GetReferencedAssemblies().ToList().ForEach(a => { if (!AppDomain.CurrentDomain.GetAssemblies().ToList().Exists(b => b.GetName().Name == a.Name)) { try { Assembly.Load(a.Name); } catch (Exception ex) { } } }); if (config.aop != null) { serviceCollection.AddSingleton <IFastAop>(config.aop); } if (!string.IsNullOrEmpty(config.NamespaceService)) { FastMap.InstanceService(serviceCollection, config.NamespaceService); } ServiceContext.Init(new ServiceEngine(serviceCollection.BuildServiceProvider())); var projectName = Assembly.GetCallingAssembly().GetName().Name; if (config.IsResource) { FastMap.InstanceMapResource(config.dbKey, config.dbFile, config.mapFile, projectName); } else { FastMap.InstanceMap(config.dbKey, config.dbFile, config.mapFile); } if (config.IsCodeFirst && !string.IsNullOrEmpty(config.NamespaceCodeFirst) && config.IsResource) { FastMap.InstanceProperties(config.NamespaceCodeFirst, config.dbFile, projectName); FastMap.InstanceTable(config.NamespaceCodeFirst, config.dbKey, config.dbFile, projectName); } if (config.IsCodeFirst && !string.IsNullOrEmpty(config.NamespaceCodeFirst) && !config.IsResource) { FastMap.InstanceProperties(config.NamespaceCodeFirst, config.dbFile); FastMap.InstanceTable(config.NamespaceCodeFirst, config.dbKey, config.dbFile); } if (!string.IsNullOrEmpty(config.NamespaceProperties) && config.IsResource) { FastMap.InstanceProperties(config.NamespaceProperties, config.dbFile, projectName); } if (!string.IsNullOrEmpty(config.NamespaceProperties) && !config.IsResource) { FastMap.InstanceProperties(config.NamespaceProperties, config.dbFile); } return(serviceCollection); }