123456789101112131415161718192021222324252627282930313233343536373839404142 |
-
- using AspectCore.Configuration;
- using AspectCore.Extensions.DependencyInjection;
- using Microsoft.AspNetCore.Builder;
- using Microsoft.Extensions.DependencyInjection;
- using System;
- using System.Data;
- using System.Linq;
- using System.Reflection;
- namespace XYY.Core.Standard.Data.Infrastructure
- {
- public static class AddDBEx
- {
- /// <summary>
- /// 数据服务注册
- /// </summary>
- /// <param name="services"></param>
- /// <param name="connection"></param>
- public static void AddDB(this IServiceCollection services, string connection)
- {
- Console.WriteLine("数据服务注册" );
- services.AddScoped<IUnitOfWork>(x => new UnitOfWork(ConnectionHelper.BuildDbConnection(connection), connection));
- //AddTransactionProcessing(services);
- }
- public static void ConfigAspectCore(this IServiceCollection services, string serviceEndName)
- {
- services.ConfigureDynamicProxy(config =>
- {
- config.Interceptors.AddTyped<ConnectionInterceptorAttribute>(
- Predicates.ForService("*" + serviceEndName + "*"));
- }
- ); ;
- }
- }
- }
|