Class MsSqlMessageStoreConfiguration.
コード例 #1
0
ファイル: Program.cs プロジェクト: stantoxt/Paramore
        private static void Main(string[] args)
        {
            var logger = LogProvider.For<Program>();

            var dbPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase.Substring(8)), "App_Data\\CommandStore.sdf");
            var connectionString = "DataSource=\"" + dbPath + "\"";
            var configuration = new MsSqlCommandStoreConfiguration(connectionString, "Commands", MsSqlCommandStoreConfiguration.DatabaseType.SqlCe);
            var commandStore = new MsSqlCommandStore(configuration, logger);

            var registry = new SubscriberRegistry();
            registry.Register<GreetingCommand, GreetingCommandHandler>();

            var tinyIoCContainer = new TinyIoCContainer();
            tinyIoCContainer.Register<IHandleRequests<GreetingCommand>, GreetingCommandHandler>();
            tinyIoCContainer.Register<IAmACommandStore>(commandStore);
            tinyIoCContainer.Register<ILog>(logger);

            var builder = CommandProcessorBuilder.With()
                .Handlers(new HandlerConfiguration(
                     subscriberRegistry: registry,
                     handlerFactory: new TinyIocHandlerFactory(tinyIoCContainer)
                    ))
                .DefaultPolicy()
                .Logger(logger)
                .NoTaskQueues()
                .RequestContextFactory(new InMemoryRequestContextFactory());

            var commandProcessor = builder.Build();

            var greetingCommand = new GreetingCommand("Ian");

            commandProcessor.Send(greetingCommand);

            var retrievedCommand = commandStore.Get<GreetingCommand>(greetingCommand.Id);

            var commandAsJson = JsonConvert.SerializeObject(retrievedCommand);

            Console.WriteLine(string.Format("Command retrieved from store: {0}", commandAsJson));

            Console.ReadLine();
        }
コード例 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object" /> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="log">The log.</param>
 public MsSqlCommandStore(MsSqlCommandStoreConfiguration configuration, ILog log)
 {
     _configuration = configuration;
     _log           = log;
 }
コード例 #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:System.Object" /> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 public MsSqlCommandStore(MsSqlCommandStoreConfiguration configuration)
     : this(configuration, LogProvider.GetCurrentClassLogger())
 {
 }
コード例 #4
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MsSqlCommandStore" /> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 /// <param name="log">The log.</param>
 public MsSqlCommandStore(MsSqlCommandStoreConfiguration configuration, ILog log)
 {
     _configuration            = configuration;
     _log                      = log;
     ContinueOnCapturedContext = false;
 }
コード例 #5
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MsSqlCommandStore" /> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 public MsSqlCommandStore(MsSqlCommandStoreConfiguration configuration)
 {
     _configuration            = configuration;
     ContinueOnCapturedContext = false;
 }
コード例 #6
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="MsSqlCommandStore" /> class.
 /// </summary>
 /// <param name="configuration">The configuration.</param>
 public MsSqlCommandStore(MsSqlCommandStoreConfiguration configuration)
     : this(configuration, LogProvider.For <MsSqlCommandStore>())
 {
 }