/// <summary> /// Use EfCore Module /// </summary> public static AppOptionsBuilder UseEfCore(this AppOptionsBuilder builder) { builder.IocRegister.Register( typeof(IRepository <,>), typeof(RepositoryBase <,>), lifeStyle: DependencyLifeStyle.Transient); builder.IocRegister.RegisterAssemblyByBasicInterface(typeof(EfCoreOptionsBuilderExtension).Assembly); return(builder); }
/// <summary> /// Use Dapper as the Orm framework /// </summary> public static AppOptionsBuilder UseDapper(this AppOptionsBuilder builder) { builder.IocRegister.Register( typeof(IRepository <,>), typeof(RepositoryBase <,>), lifeStyle: DependencyLifeStyle.Transient); builder.IocRegister.RegisterAssemblyByBasicInterface(typeof(DapperOptionsBuilderExtension).Assembly); DapperExtensions.DapperExtensions.DefaultMapper = typeof(PluralizedAutoClassMapper <>); return(builder); }
/// <summary> /// Use unit of work /// </summary> public static AppOptionsBuilder UseUnitOfWork(this AppOptionsBuilder builder, Action <UnitOfWorkCoreOptionsBuilder> options = null) { var uowOptionsBuilder = new UnitOfWorkCoreOptionsBuilder(); options?.Invoke(uowOptionsBuilder); uowOptionsBuilder.Build(builder.IocRegister); builder.IocRegister.RegisterAssemblyByBasicInterface(typeof(UnitOfWorkDapperOptionsBuilderExtension).Assembly); return(builder); }
/// <summary> /// Use AutoMapper /// </summary> public static AppOptionsBuilder UseAutoMapper(this AppOptionsBuilder builder, Action <IMapperConfigurationExpression> config = null) { Mapper.Initialize( options => { options.ValidateInlineMaps = false; config?.Invoke(options); }); return(builder); }
/// <summary> /// Add an application framework service /// </summary> public static IServiceProvider AddCreekdream(this IServiceCollection services, Action <AppOptionsBuilder> options = null) { if (services == null) { throw new ArgumentNullException(nameof(services)); } var builder = new AppOptionsBuilder(); options?.Invoke(builder); return(builder.Build(services)); }
/// <summary> /// Use Autofac as an injection container /// </summary> public static AppOptionsBuilder UseWindsor(this AppOptionsBuilder builder) { builder.IocRegister = new WindsorIocRegister(); builder.IocRegister.Register <IIocResolver, WindsorIocResolver>(DependencyLifeStyle.Transient); return(builder); }