Exemplo n.º 1
0
        protected override void Setup(FeatureConfigurationContext context)
        {
            if (!context.Services.Any(descriptor => descriptor.ServiceType == typeof(IProvideCosmosClient)))
            {
                context.Services.AddSingleton(context.Settings.Get <IProvideCosmosClient>());
            }

            var databaseName = context.Settings.Get <string>(SettingsKeys.DatabaseName);

            ContainerInformation?defaultContainerInformation = null;

            if (context.Settings.TryGet <ContainerInformation>(out var info))
            {
                defaultContainerInformation = info;
            }

            var currentSharedTransactionalBatchHolder = new CurrentSharedTransactionalBatchHolder();

            context.Services.AddTransient(_ => currentSharedTransactionalBatchHolder.Current.Create());

            context.Services.AddSingleton(b => new ContainerHolderResolver(b.GetService <IProvideCosmosClient>(), defaultContainerInformation, databaseName));
            context.Services.AddSingleton <ISynchronizedStorage>(b => new StorageSessionFactory(b.GetService <ContainerHolderResolver>(), currentSharedTransactionalBatchHolder));
            context.Services.AddSingleton <ISynchronizedStorageAdapter>(b => new StorageSessionAdapter(currentSharedTransactionalBatchHolder));

            context.Pipeline.Register(new CurrentSharedTransactionalBatchBehavior(currentSharedTransactionalBatchHolder), "Manages the lifecycle of the current storage session.");
        }
Exemplo n.º 2
0
 public StorageSessionAdapter(CurrentSharedTransactionalBatchHolder currentSharedTransactionalBatchHolder)
 {
     this.currentSharedTransactionalBatchHolder = currentSharedTransactionalBatchHolder;
 }
Exemplo n.º 3
0
 public CurrentSharedTransactionalBatchBehavior(CurrentSharedTransactionalBatchHolder currentTransactionalBatchHolder)
 {
     this.currentTransactionalBatchHolder = currentTransactionalBatchHolder;
 }
 public Scope(CurrentSharedTransactionalBatchHolder sharedTransactionalBatchHolder)
 {
     this.sharedTransactionalBatchHolder = sharedTransactionalBatchHolder;
 }
Exemplo n.º 5
0
 public StorageSessionFactory(ContainerHolderResolver containerHolderResolver, CurrentSharedTransactionalBatchHolder currentSharedTransactionalBatchHolder)
 {
     this.containerHolderResolver = containerHolderResolver;
     this.currentSharedTransactionalBatchHolder = currentSharedTransactionalBatchHolder;
 }