Ejemplo n.º 1
0
        protected async Task <(IStreamStore, Action)> GetStore(CancellationToken cancellationToken)
        {
            IStreamStore streamStore = null;
            IDisposable  disposable  = null;

            Output.WriteLine(ConsoleColor.Yellow, "Store type:");
            await new Menu()
            .AddSync("InMem", () => streamStore = new InMemoryStreamStore())
            .Add("MS SQL V2 (Docker)",
                 async _ =>
            {
                var fixture = new MsSqlStreamStoreDb("dbo");
                Console.WriteLine(fixture.ConnectionString);
                streamStore = await fixture.GetStreamStore();
                disposable  = fixture;
            })
            .Add("MS SQL V3 (Docker)",
                 async _ =>
            {
                var fixture = new MsSqlStreamStoreDbV3("dbo");
                Console.WriteLine(fixture.ConnectionString);
                streamStore = await fixture.GetStreamStore();
                disposable  = fixture;
            })
            .AddSync("MS SQL V3 (LocalDB)",
                     () =>
            {
                var sqlLocalDb = new SqlLocalDb();
                Console.WriteLine(sqlLocalDb.ConnectionString);
                streamStore = sqlLocalDb.StreamStore;
                disposable  = sqlLocalDb;
            })
            .Add("Postgres (Docker)",
                 async ct =>
            {
                var fixture = new PostgresStreamStoreDb("dbo");
                Console.WriteLine(fixture.ConnectionString);
                streamStore = await fixture.GetPostgresStreamStore(true);
                disposable  = fixture;
            })
            .Add("Postgres (Server)",
                 async ct =>
            {
                Console.Write("Enter the connection string: ");
                var connectionString = Console.ReadLine();
                var fixture          = new PostgresStreamStoreDb("dbo", connectionString);
                Console.WriteLine(fixture.ConnectionString);
                streamStore = await fixture.GetPostgresStreamStore(true);
                disposable  = fixture;
            })
            .Display(cancellationToken);

            return(
                streamStore,
                () =>
            {
                streamStore.Dispose();
                disposable?.Dispose();
            });
        }
Ejemplo n.º 2
0
        protected (IStreamStore, Action) GetStore()
        {
            IStreamStore streamStore = null;
            IDisposable  disposable  = null;

            Output.WriteLine(ConsoleColor.Yellow, "Store type:");
            new Menu()
            .Add("InMem", () => streamStore = new InMemoryStreamStore())
            .Add("MS SQL V2 (Docker)",
                 () =>
            {
                var fixture = new MsSqlStreamStoreFixture("dbo");
                Console.WriteLine(fixture.ConnectionString);
                streamStore = fixture.GetStreamStore().Result;
                disposable  = fixture;
            })
            .Add("MS SQL V3 (Docker)",
                 () =>
            {
                var fixture = new MsSqlStreamStoreV3Fixture("dbo");
                Console.WriteLine(fixture.ConnectionString);
                streamStore = fixture.GetStreamStore().Result;
                disposable  = fixture;
            })
            .Add("MS SQL V3 (LocalDB)",
                 () =>
            {
                var sqlLocalDb = new SqlLocalDb();
                Console.WriteLine(sqlLocalDb.ConnectionString);
                streamStore = sqlLocalDb.StreamStore;
                disposable  = sqlLocalDb;
            })
            .Add("Postgres (Docker)",
                 () =>
            {
                var fixture = new PostgresStreamStoreFixture("dbo");
                Console.WriteLine(fixture.ConnectionString);
                streamStore = fixture.GetPostgresStreamStore(true).Result;
                disposable  = fixture;
            })
            .Add("Postgres (Server)",
                 () =>
            {
                Console.Write("Enter the connection string: ");
                var connectionString = Console.ReadLine();
                var fixture          = new PostgresStreamStoreFixture("dbo", connectionString);
                Console.WriteLine(fixture.ConnectionString);
                streamStore = fixture.GetPostgresStreamStore(true).Result;
                disposable  = fixture;
            })
            .Display();

            return(
                streamStore,
                () =>
            {
                streamStore.Dispose();
                disposable?.Dispose();
            });
        }