public static void Add <TKey, TType, TSpecialization>(this IFactoryBuilder <TKey, TType> builder, TKey key, Action <TSpecialization> configure = null) where TKey : IComparable <TKey> where TType : class where TSpecialization : TType, new() { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } builder.Add(key, new InstanceFactory <TType, TSpecialization>(() => new TSpecialization(), configure)); }
public static void Configure(IFactoryBuilder factoryBuilder) { var assembly = typeof(Startup) .GetTypeInfo() .Assembly; factoryBuilder .SetupMapper(config => { config.AddProfile <ExamsMappings>(); }) .SetupCommandHandlers(assembly) .SetupQueryHandlers(assembly) .SubscribeToSettings <ExamsSettings>("Exams") .RegisterScoped <AtsExamsContext>() .RegisterScoped <IExamsRepository, AtsExamsRepository>(); }
public static void Add <TKey, TType, TSpecialization>(this IFactoryBuilder <TKey, TType> builder, TKey key, IServiceProvider serviceProvider, Action <TSpecialization> configure = null) where TKey : IComparable <TKey> where TType : class where TSpecialization : TType { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } builder.Add(key, new InstanceFactory <TType, TSpecialization>(() => (TSpecialization)serviceProvider.GetService(typeof(TSpecialization)), configure)); }
public static void Configure(IFactoryBuilder factoryBuilder) { var assembly = typeof(Startup) .GetTypeInfo() .Assembly; factoryBuilder .SetupMapper(config => { config.AddProfile <AuthMappings>(); }) .SetupCommandHandlers(assembly) .SetupQueryHandlers(assembly) .SubscribeToSettings <AuthSettings>("Auth") .SubscribeToSettings <JwtSettings>("Jwt") .RegisterScoped <AtsUsersContext>() .RegisterScoped <IPasswordService, PasswordService>() .RegisterScoped <ITokenService, TokenService>() .RegisterScoped <IUsersRepository, AtsUsersRepository>(); }
public static void Add <TKey, TType>(this IFactoryBuilder <TKey, TType> builder, TKey key, Type specializationType, IServiceProvider serviceProvider, Action <TType> configure = null) where TKey : IComparable <TKey> where TType : class { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (!typeof(TType).IsAssignableFrom(specializationType)) { throw new ArgumentOutOfRangeException(nameof(specializationType), $"{specializationType} is not a {typeof(TType)}"); } if (serviceProvider == null) { throw new ArgumentNullException(nameof(serviceProvider)); } builder.Add(key, new InstanceFactory <TType, TType>(() => (TType)serviceProvider.GetService(specializationType), configure)); }