Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            // Using StructureMap for IoC.  You can use Ninject, AutoFac, Windsor, or whatever
            // supports the methods you need to override in SeekUHostConfiguration<T>
            var host = new SeekUHostConfiguration<SeekUDemoDependencyResolver>();

            // Configure the host to use SQL to store events and snapshots.  You don't have to use
            // the configuration action - both providers will default to a connection string
            // named "SeekU."  This simply shows how you can configure each provider at runtime.
            host
                // Sample of using configuration actions to set connectionstrings
                .ForEventStore().Use<SqlEventStore>(store => { store.ConnectionStringName = "DemoConnectionString"; })
                // This could be a different connection if necessary
                .ForSnapshotStore().Use<SqlSnapshotStore>(store => { store.ConnectionStringName = "DemoConnectionString"; });

            // Using the default conenction string would look like this (less verbose):
            //config.ForEventStore().Use<SqlEventStore>().ForSnapshotStore().Use<SqlSnapshotStore>();

            var bus = host.GetCommandBus();

            // I'm not a proponent of Guids for primary keys.  This method returns
            // a sequential Guid to make database sorting behave like integers.
            // http://www.informit.com/articles/article.asp?p=25862
            var id = SequentialGuid.NewId();

            // Create the account
            bus.Send(new CreateNewAccountCommand(id, 950));

            // Use the account to create a history of events including a snapshot
            bus.Send(new DebitAccountCommand(id, 50));
            bus.Send(new CreditAccountCommand(id, 120));
            bus.Send(new DebitAccountCommand(id, 350));

            Console.Read();
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            // Using StructureMap for IoC.  You can use Ninject, AutoFac, Windsor, or whatever
            // supports the methods you need to override in SeekUHostConfiguration<T>
            var host = new SeekUHostConfiguration <SeekUDemoDependencyResolver>();

            // Configure file-based event storeage
            host.ForEventStore().Use <JsonFileEventStore>()
            // Example of using an optional configuration action.  In this cas it sets the snapshot store's file name
            .ForSnapshotStore().Use <JsonFileSnapshotStore>(store =>
            {
                store.FileName = "snapshot-instance.json";
            });

            var bus = host.GetCommandBus();

            // I'm not a proponent of Guids for primary keys.  This method returns
            // a sequential Guid to make database sorting behave like integers.
            // http://www.informit.com/articles/article.asp?p=25862
            var id = SequentialGuid.NewId();

            // Create the account
            bus.Send(new CreateNewAccountCommand(id, 950));

            // Use the account to create a history of events including a snapshot
            bus.Send(new DebitAccountCommand(id, 50));
            bus.Send(new CreditAccountCommand(id, 120));
            bus.Send(new DebitAccountCommand(id, 350));

            Console.Read();
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            // Use MongoDB for event and snapshot storage
            var host = new SeekUHostConfiguration <SeekUDemoDependencyResolver>();

            host.ForEventStore().Use <MongoEventStore>()
            .ForSnapshotStore().Use <MongoSnapshotStore>();

            var bus = host.GetCommandBus();

            // I'm not a proponent of Guids for primary keys.  This method returns
            // a sequential Guid to make database sorting behave like integers.
            // http://www.informit.com/articles/article.asp?p=25862
            var id = SequentialGuid.NewId();

            // Create the account
            bus.Send(new CreateNewAccountCommand(id, 950));

            // Use the account to create a history of events including a snapshot
            bus.Send(new DebitAccountCommand(id, 50));
            bus.Send(new CreditAccountCommand(id, 120));
            bus.Send(new DebitAccountCommand(id, 350));

            Console.Read();
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            // Using StructureMap for IoC.  You can use Ninject, AutoFac, Windsor, or whatever
            // supports the methods you need to override in SeekUHostConfiguration<T>
            var host = new SeekUHostConfiguration<SeekUDemoDependencyResolver>();

            // Configure file-based event storeage
            host.ForEventStore().Use<JsonFileEventStore>()
                // Example of using an optional configuration action.  In this cas it sets the snapshot store's file name
                .ForSnapshotStore().Use<JsonFileSnapshotStore>(store =>
                {
                    store.FileName = "snapshot-instance.json";
                });

            var bus = host.GetCommandBus();

            // I'm not a proponent of Guids for primary keys.  This method returns
            // a sequential Guid to make database sorting behave like integers.
            // http://www.informit.com/articles/article.asp?p=25862
            var id = SequentialGuid.NewId();

            // Create the account
            bus.Send(new CreateNewAccountCommand(id, 950));

            // Use the account to create a history of events including a snapshot
            bus.Send(new DebitAccountCommand(id, 50));
            bus.Send(new CreditAccountCommand(id, 120));
            bus.Send(new DebitAccountCommand(id, 350));

            Console.Read();
        }
Ejemplo n.º 5
0
        static void Main(string[] args)
        {
            // Using StructureMap for IoC.  You can use Ninject, AutoFac, Windsor, or whatever
            // supports the methods you need to override in SeekUHostConfiguration<T>
            var host = new SeekUHostConfiguration <SeekUDemoDependencyResolver>();

            // Configure the host to use SQL to store events and snapshots.  You don't have to use
            // the configuration action - both providers will default to a connection string
            // named "SeekU."  This simply shows how you can configure each provider at runtime.
            host
            // Sample of using configuration actions to set connectionstrings
            .ForEventStore().Use <SqlEventStore>(store => { store.ConnectionStringName = "DemoConnectionString"; })
            // This could be a different connection if necessary
            .ForSnapshotStore().Use <SqlSnapshotStore>(store => { store.ConnectionStringName = "DemoConnectionString"; });

            // Using the default conenction string would look like this (less verbose):
            //config.ForEventStore().Use<SqlEventStore>().ForSnapshotStore().Use<SqlSnapshotStore>();

            var bus = host.GetCommandBus();

            // I'm not a proponent of Guids for primary keys.  This method returns
            // a sequential Guid to make database sorting behave like integers.
            // http://www.informit.com/articles/article.asp?p=25862
            var id = SequentialGuid.NewId();

            // Create the account
            bus.Send(new CreateNewAccountCommand(id, 950));

            // Use the account to create a history of events including a snapshot
            bus.Send(new DebitAccountCommand(id, 50));
            bus.Send(new CreditAccountCommand(id, 120));
            bus.Send(new DebitAccountCommand(id, 350));

            Console.Read();
        }
Ejemplo n.º 6
0
        static void Main(string[] args)
        {
            // Use MongoDB for event and snapshot storage
            var host = new SeekUHostConfiguration<SeekUDemoDependencyResolver>();
            // Update with your connection string
            const string connectionString =
                "DefaultEndpointsProtocol=https;AccountName=[Your account name];AccountKey[Your account key]";

            host
                .ForEventStore().Use<AzureTableEventStore>(store =>
                {
                    store.TableConnectionString = connectionString;
                })
                .ForSnapshotStore().Use<AzureBlobSnapshotStore>(store =>
                {
                    store.BlobConnectionString = connectionString;
                });

            var bus = host.GetCommandBus();

            // I'm not a proponent of Guids for primary keys.  This method returns
            // a sequential Guid to make database sorting behave like integers.
            // http://www.informit.com/articles/article.asp?p=25862
            var id = SequentialGuid.NewId();

            // Create the account
            bus.Send(new CreateNewAccountCommand(id, 95));
            Console.WriteLine("Azure event created");

            // Use the account to create a history of events including a snapshot
            bus.Send(new DebitAccountCommand(id, 5));
            Console.WriteLine("Azure event created");

            bus.Send(new CreditAccountCommand(id, 12));
            Console.WriteLine("Azure event created");
            Console.WriteLine("Azure snapshot created");

            bus.Send(new DebitAccountCommand(id, 35));
            Console.WriteLine("Azure event created");

            Console.Read();
        }
Ejemplo n.º 7
0
        static void Main(string[] args)
        {
            // Use MongoDB for event and snapshot storage
            var host = new SeekUHostConfiguration <SeekUDemoDependencyResolver>();
            // Update with your connection string
            const string connectionString =
                "DefaultEndpointsProtocol=https;AccountName=[Your account name];AccountKey[Your account key]";

            host
            .ForEventStore().Use <AzureTableEventStore>(store =>
            {
                store.TableConnectionString = connectionString;
            })
            .ForSnapshotStore().Use <AzureBlobSnapshotStore>(store =>
            {
                store.BlobConnectionString = connectionString;
            });

            var bus = host.GetCommandBus();

            // I'm not a proponent of Guids for primary keys.  This method returns
            // a sequential Guid to make database sorting behave like integers.
            // http://www.informit.com/articles/article.asp?p=25862
            var id = SequentialGuid.NewId();

            // Create the account
            bus.Send(new CreateNewAccountCommand(id, 95));
            Console.WriteLine("Azure event created");

            // Use the account to create a history of events including a snapshot
            bus.Send(new DebitAccountCommand(id, 5));
            Console.WriteLine("Azure event created");

            bus.Send(new CreditAccountCommand(id, 12));
            Console.WriteLine("Azure event created");
            Console.WriteLine("Azure snapshot created");

            bus.Send(new DebitAccountCommand(id, 35));
            Console.WriteLine("Azure event created");

            Console.Read();
        }
Ejemplo n.º 8
0
        static void Main(string[] args)
        {
            // Use MongoDB for event and snapshot storage
            var host = new SeekUHostConfiguration<SeekUDemoDependencyResolver>();
            host.ForEventStore().Use<MongoEventStore>()
                .ForSnapshotStore().Use<MongoSnapshotStore>();

            var bus = host.GetCommandBus();

            // I'm not a proponent of Guids for primary keys.  This method returns
            // a sequential Guid to make database sorting behave like integers.
            // http://www.informit.com/articles/article.asp?p=25862
            var id = SequentialGuid.NewId();

            // Create the account
            bus.Send(new CreateNewAccountCommand(id, 950));

            // Use the account to create a history of events including a snapshot
            bus.Send(new DebitAccountCommand(id, 50));
            bus.Send(new CreditAccountCommand(id, 120));
            bus.Send(new DebitAccountCommand(id, 350));

            Console.Read();
        }