public static StorageBuilder AddEntityFrameworkCore <TDbContext>(this StorageBuilder storageBuilder, Action <DbContextOptionsBuilder> optionsAction) where TDbContext : StorageContext { storageBuilder.Services.TryAddTransient <IDbContextProvider <TDbContext>, DefaultDbContextProvider <TDbContext> >(); storageBuilder.Services.AddDbContext <TDbContext>(optionsAction, ServiceLifetime.Transient, ServiceLifetime.Transient); RegisterRepository <TDbContext>(storageBuilder.Services); return(storageBuilder); }
/// <summary> /// Adds MongoDB storage for any unregistered type. /// </summary> public static StorageBuilder AddMongoAny(this StorageBuilder builder) { builder.Services .ReplaceScoped(typeof(IStorageProvider <>), typeof(MongoStorageProvider <>)) .ConfigureSerializer(b => b.AddJsonTypeAny()); return(builder); }
/// <summary> /// Adds local storage for any unregistered type. /// </summary> public static StorageBuilder AddHistoricalLocalAny(this StorageBuilder builder) { builder.Services .ReplaceSingleton(typeof(IHistoricalStorageProvider <>), typeof(LocalHistoricalStorageProvider <>)) .ConfigureSerializer(b => b.AddJsonTypeAny()); return(builder); }
/// <summary> /// Adds local partitioned storage for any unregistered type. /// </summary> public static StorageBuilder AddLocalPartitionedAny(this StorageBuilder builder) { builder.Services .ReplaceSingleton(typeof(IPartitionedStorageProvider <>), typeof(LocalPartitionedStorageProvider <>)) .ConfigureSerializer(b => b.AddJsonTypeAny()); return(builder); }
public void storage_builder() { IStorage storage = new StorageBuilder() .Register <hello_world>() .Register <Factory>() .Build(); }
public static FightBuilder ConfigureStorage(this FightBuilder fightBuilder, Action <StorageBuilder> setupAction) { StorageBuilder builder = new StorageBuilder(fightBuilder.Services); setupAction?.Invoke(builder); builder.Build(); return(fightBuilder); }
public void builder_Object_Services_is_not_empty_after_Register() { StorageBuilder builder = new StorageBuilder(); exec(builder, typeof(TestClass)); Assert.IsNotEmpty(builder.Object.Services.GetServices()); }
public void builder_Object_Services_count_is_one() { StorageBuilder builder = new StorageBuilder(); exec(builder, typeof(TestClass)); Assert.IsTrue(builder.Object.Services.GetServices().Count() == 1); }
public void builder_Object_Services_not_null() { StorageBuilder builder = new StorageBuilder(); exec(builder, typeof(TestClass)); Assert.NotNull(builder.Object.Services); }
public void builder_Object_is_assignable_to_IStorage() { StorageBuilder builder = new StorageBuilder(); exec(builder, typeof(TestClass)); Assert.IsTrue(builder.Object is IStorage); }
public void builder_Object_is_instance_of_Storage() { StorageBuilder builder = new StorageBuilder(); exec(builder, typeof(TestClass)); Assert.IsInstanceOf <Storage>(builder.Object); }
/// <summary> /// Apply a list of configuration instances <paramref name="storageConfigurations" />. /// </summary> public static StorageBuilder AddConfiguration(this StorageBuilder builder, params IStorageConfiguration[] storageConfigurations) { foreach (var config in storageConfigurations) { config.Configure(builder); } return(builder); }
/// <summary> /// Configures the storage to connect a MongoDB database. /// </summary> public static StorageBuilder UseMongo(this StorageBuilder builder, IConfigurationSection configuration) { builder.Services .AddMongoClientFactory() .ConfigureMongoOptions(configuration) .ConfigureMongoStoringOptions(_ => { }); return(builder); }
/// <summary> /// Adds partitioned MongoDB storage for any unregistered type. /// </summary> public static StorageBuilder AddMongoPartitionedAny(this StorageBuilder builder) { builder .AddMongoHistoricalAny() .Services .ReplaceScoped(typeof(IPartitionedStorageProvider <>), typeof(MongoPartitionedStorageProvider <>)) .ConfigureSerializer(b => b.AddJsonTypeAny()); return(builder); }
public IDbCommand CreateInsertCommand(IEnumerable <IDicomDataParameter> conditions) { IDbCommand insertCommand = CreateCommand( ); StorageBuilder.BuildInsert(conditions, insertCommand); SetConnectionIfNull(insertCommand); return(insertCommand); }
/// <summary> /// Adds local partitioned storage of <paramref name="valueType"/> with <paramref name="keyType"/>. /// </summary> public static StorageBuilder AddLocalPartitioned(this StorageBuilder builder, Type keyType, Type valueType) { var serviceType = typeof(IPartitionedStorageProvider <>).MakeGenericType(valueType); var implementationType = typeof(LocalPartitionedStorageProvider <>).MakeGenericType(valueType); builder.Services .ReplaceSingleton(serviceType, implementationType) .ConfigureSerializer(b => b.AddJsonType(keyType).AddJsonType(valueType)); return(builder); }
public void builder_Object_Services_contains_TestClass() { Type testClassType = typeof(TestClass); StorageBuilder builder = new StorageBuilder(); exec(builder, testClassType); Assert.NotNull(builder.Object.Services.GetServices().FirstOrDefault(x => x.Registration.TargetType == testClassType)); }
public IDbCommand CreateDeleteInstanceCommand(string sopInstanceUID) { IDbCommand command = CreateCommand( ); StorageBuilder.BuildDelete(sopInstanceUID, command); SetConnectionIfNull(command); return(command); }
/// <summary> /// Adds MongoDB storage of <paramref name="valueType"/> with <paramref name="keyType"/>. /// </summary> public static StorageBuilder AddMongo(this StorageBuilder builder, Type keyType, Type valueType) { var serviceType = typeof(IStorageProvider <>).MakeGenericType(valueType); var implementationType = typeof(MongoStorageProvider <>).MakeGenericType(valueType); builder.Services .ReplaceScoped(serviceType, implementationType) .ConfigureSerializer(b => b.AddJsonType(keyType).AddJsonType(valueType)); return(builder); }
public void returns_not_null_if_target_was_interface_of_registered_class() { IStorage storage = new StorageBuilder() .Register <TestClass>() .Build(); IReadOnlyContainer container = ContainerFactory.ReadOnlyContainer(storage); Assert.NotNull(exec <ITestClass>(container)); }
public void returns_instanceof_TestClass_if_target_was_ITestClass() { IStorage storage = new StorageBuilder() .Register <TestClass>() .Build(); IReadOnlyContainer container = ContainerFactory.ReadOnlyContainer(storage); Assert.IsInstanceOf <TestClass>(exec <ITestClass>(container)); }
/// <summary> /// Default constructor /// </summary> private UserWrapper() { AuthBuilder authBuilder = AuthBuilder.GetInstance(); this.IUserMgr = authBuilder.GetManager <IUserMgr>(AuthBuilder.IUSERMGR); this.IUserRoleMgr = authBuilder.GetManager <IUserRoleMgr>(AuthBuilder.IUSERROLEMGR); StorageBuilder storageBuilder = StorageBuilder.GetInstance(); this.IStorageBlobMgr = storageBuilder.GetManager <IStorageBlobMgr>(StorageBuilder.ISTORAGEBLOBMGR); this.EmailWrapper = EmailWrapper.GetInstance(); }
public void another_test() { IStorage storage = new StorageBuilder() .Register <Tobi>() .Register <IFlorka>() .Build(); IContainer container = ContainerFactory.Container(storage); Florka florka = container.Resolve <Florka>(); }
public ContainerTests() { _container = new Container(_ => { _.IncludeRegistry <CrispinRestRegistry>(); _.IncludeRegistry <MediatrRegistry>(); _.For(typeof(ILogger <>)).Use(typeof(FakeLogger <>)); _.For <IStorage>().Use(StorageBuilder.Configure(new InMemoryStorage())); }); }
private static void InjectStrongConfiguration(WebHostBuilderContext host, IServiceCollection services) { var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddJsonFile($"appsettings.{host.HostingEnvironment.EnvironmentName}.json", optional: true) .Build(); var config = builder.Get <CrispinConfiguration>() ?? new CrispinConfiguration(); services.AddSingleton(StorageBuilder.Build(config)); services.AddSingleton(config); }
public RoleTestBase() { //Context = StorageBuilder.GetContext(); //UnitOfWork = (UnitOfWork)StorageBuilder.GetUnitOfWork(Context); InMemoryDatabaseContext = StorageBuilder.GetInMemContextUserAndRoleData(); UnitOfWork = (UnitOfWork)StorageBuilder.GetUnitOfWork(InMemoryDatabaseContext); var configuration = new MapperConfiguration(cfg => cfg.AddProfile <IdentityEntitiesToModelsMappingProfile>()); //var configuration = new MapperConfiguration(cfg => new IdentityEntitiesToModelsMappingProfile()); var mapper = configuration.CreateMapper(); RoleStore = new RoleStore(UnitOfWork, mapper); }
public void dont_throws_if_target_was_registered_with_instance() { TestClass test = new TestClass(); IStorage storage = new StorageBuilder() .RegisterObject(test) .Build(); IReadOnlyContainer container = ContainerFactory.ReadOnlyContainer(storage); Assert.DoesNotThrow(() => exec <TestClass>(container)); }
public void returns_same_instances_if_target_was_registered_with_instance() { TestClass test = new TestClass(); IStorage storage = new StorageBuilder() .RegisterObject(test) .Build(); IReadOnlyContainer container = ContainerFactory.ReadOnlyContainer(storage); Assert.AreEqual(test, exec <TestClass>(container)); }
/// <summary> /// 添加存储服务 /// </summary> /// <param name="services"><see cref="IServiceCollection"/></param> /// <param name="builer"><see cref="StorageBuilder"/> 配置</param> /// <param name="storageName">Storage的名称</param> /// <returns></returns> public static IServiceCollection AddEFStorage(this IServiceCollection services, Action <IStorageBuilder> builer, string storageName = GrainStorage.DefaultName) { //配置差异对比服务 services.TryAddSingleton <IEntityChangeDetector, EntityChangeDetector>(); services.TryAddSingleton <IEntityChangeManagerFactory, EntityChangeManagerFactory>(); //配置Orleans 的存储配置 services.AddTransientNamedService <IGrainStorage, GrainStorage>(storageName); //对应实体的仓储配置 var builder = new StorageBuilder(services); builer.Invoke(builder); return(services); }
/// <summary> /// Configures the storage which required by Parbad for saving and loading data. /// </summary> /// <param name="builder"></param> /// <param name="configureStorage"></param> public static IParbadBuilder ConfigureStorage(this IParbadBuilder builder, Action <IStorageBuilder> configureStorage) { if (builder == null) { throw new ArgumentNullException(nameof(builder)); } if (configureStorage == null) { throw new ArgumentNullException(nameof(configureStorage)); } var storageBuilder = new StorageBuilder(builder.Services); configureStorage(storageBuilder); return(builder); }