Example #1
0
        public ShellExecuteCommandFactory(ICommandStore store)
        {
            _store = store;

            AddDirectoryCommands(@"C:\dev\shortcuts");
            //AddDirectoryCommands(Environment.GetFolderPath(Environment.SpecialFolder.Desktop));
            //AddDirectoryCommands(GetStartMenuFolder());
        }
 /// <summary>
 /// Creates new instance.
 /// </summary>
 /// <param name="eventStore">The underlaying event store.</param>
 /// <param name="commandStore">The underlaying command store.</param>
 /// <param name="eventFormatter">The formatter for serializing event payloads.</param>
 /// <param name="commandFormatter">The formatter for serializing commands.</param>
 /// <param name="factory">The process root factory.</param>
 /// <param name="eventDispatcher">The dispatcher for newly created events in the processes.</param>
 /// <param name="commandDispatcher">The dispatcher for newly created commands in the processes.</param>
 /// <param name="snapshotProvider">The snapshot provider.</param>
 /// <param name="snapshotStore">The store for snapshots.</param>
 public ProcessRootRepository(IEventStore eventStore, ICommandStore commandStore, IFormatter eventFormatter, ISerializer commandFormatter,
                              IAggregateRootFactory <T> factory, IEventDispatcher eventDispatcher, ICommandDispatcher commandDispatcher, ISnapshotProvider snapshotProvider, ISnapshotStore snapshotStore)
     : base(eventStore, eventFormatter, factory, eventDispatcher, snapshotProvider, snapshotStore)
 {
     Ensure.NotNull(commandStore, "commandStore");
     Ensure.NotNull(commandDispatcher, "commandDispatcher");
     Ensure.NotNull(commandFormatter, "commandFormatter");
     this.commandStore      = commandStore;
     this.commandFormatter  = commandFormatter;
     this.commandDispatcher = commandDispatcher;
 }
Example #3
0
        /// <summary>
        /// First time initialization and reconfig in case of restore
        /// </summary>
        /// <param name="model"></param>
        private void Configure(Model model)
        {
            _commandStore    = _config.CreateCommandStore();
            _snapshotStore   = _config.CreateSnapshotStore();
            _journalAppender = JournalAppender.Create(model.Revision + 1, _commandStore);
            _kernel          = _config.CreateKernel(model);
            _kernel.SetSynchronizer(_synchronizer);

            //Capture events emitted during Command.Execute
            model.Events.Subscribe(e => _capturedEvents.Add(e));
        }
Example #4
0
 public CommandSender(IResolver resolver,
                      IEventPublisher eventPublisher,
                      IEventFactory eventFactory,
                      IEventStore eventStore,
                      ICommandStore commandStore)
 {
     _resolver       = resolver;
     _eventPublisher = eventPublisher;
     _eventFactory   = eventFactory;
     _eventStore     = eventStore;
     _commandStore   = commandStore;
 }
Example #5
0
        private void AssertJournalEntriesAreSequential(ICommandStore storage)
        {
            ulong expected = 1;

            Console.WriteLine("JournalEntry Ids:");
            foreach (var journalEntry in storage.CommandEntries())
            {
                Console.WriteLine(journalEntry.Id);
                Assert.AreEqual(expected, journalEntry.Id);
                expected++;
            }
        }
 public CommandSenderAsync(IHandlerResolver handlerResolver,
                           IEventPublisherAsync eventPublisherAsync,
                           IEventFactory eventFactory,
                           IEventStore eventStore,
                           ICommandStore commandStore)
 {
     _handlerResolver     = handlerResolver;
     _eventPublisherAsync = eventPublisherAsync;
     _eventFactory        = eventFactory;
     _eventStore          = eventStore;
     _commandStore        = commandStore;
 }
 public PriorityProcessor(
     IRoomService roomService,
     ICommandStore commandService,
     IHttpService httpService,
     int roomId)
 {
     _roomService    = roomService;
     _commandStore   = commandService;
     _httpService    = httpService;
     _roomId         = roomId;
     _nativeCommands = LoadNativeCommands().ToDictionary(kvp => kvp.commandName, kvp => kvp.implementer);
 }
Example #8
0
 public CommandSender(IHandlerResolver handlerResolver,
                      IEventPublisher eventPublisher,
                      IEventFactory eventFactory,
                      IEventStore eventStore,
                      ICommandStore commandStore)
 {
     _eventPublisher  = eventPublisher;
     _eventFactory    = eventFactory;
     _eventStore      = eventStore;
     _commandStore    = commandStore;
     _handlerResolver = handlerResolver;
 }
 public CommandExecutor(
     IRuntime runtime,
     ILifetimeScope lifetimeScope,
     ICommandStore commandStore,
     ICommandPermissionBuilder commandPermissionBuilder,
     IEventBus eventBus)
 {
     m_Runtime                  = runtime;
     m_LifetimeScope            = lifetimeScope;
     m_CommandStore             = commandStore;
     m_CommandPermissionBuilder = commandPermissionBuilder;
     m_EventBus                 = eventBus;
 }
Example #10
0
 public LineReaderService(
     ICommandContextFactory commandContextFactory,
     ICommandExecutor commandExecutor,
     ICommandParser commandParser,
     ICommandStore commandStore,
     ILogger <LineReaderService> logger)
 {
     _commandContextFactory = commandContextFactory;
     _commandExecutor       = commandExecutor;
     _commandParser         = commandParser;
     _commandStore          = commandStore;
     _logger = logger;
 }
Example #11
0
 public CommandSenderAsync(
     IResolver resolver,
     IEventPublisherAsync eventPublisherAsync,
     IEventFactory eventFactory,
     IEventStore eventStore,
     ICommandStore commandStore)
 {
     this.resolver            = resolver;
     this.eventPublisherAsync = eventPublisherAsync;
     this.eventFactory        = eventFactory;
     this.eventStore          = eventStore;
     this.commandStore        = commandStore;
 }
Example #12
0
 public CommandExecutionService(IPositionRequestService positionRequestService,
                                IOrderRequestService orderRequestService,
                                IPositionCache positionCache,
                                IOrderCache orderCache,
                                ICommandStore commandStore,
                                ILogger <CommandExecutionService> logger)
 {
     _positionRequestService = positionRequestService;
     _orderRequestService    = orderRequestService;
     _positionCache          = positionCache;
     _orderCache             = orderCache;
     _commandStore           = commandStore;
     _logger = logger;
 }
Example #13
0
 public CommandHelp(
     IPermissionChecker permissionChecker,
     ICommandStore commandStore,
     IServiceProvider serviceProvider,
     ICommandPermissionBuilder commandPermissionBuilder,
     ICommandContextBuilder commandContextBuilder,
     IOpenModStringLocalizer stringLocalizer) : base(serviceProvider)
 {
     m_PermissionChecker        = permissionChecker;
     m_CommandStore             = commandStore;
     m_CommandPermissionBuilder = commandPermissionBuilder;
     m_CommandContextBuilder    = commandContextBuilder;
     m_StringLocalizer          = stringLocalizer;
 }
Example #14
0
 public PluginHelpWriter(
     ICommandPermissionBuilder permissionBuilder,
     IPermissionRegistry permissionRegistry,
     IOpenModPlugin plugin,
     ICommandStore commandStore,
     ICommandContextBuilder commandContextBuilder)
 {
     m_PermissionBuilder         = permissionBuilder;
     m_PermissionRegistry        = permissionRegistry;
     m_Plugin                    = plugin;
     m_CommandStore              = commandStore;
     m_CommandContextBuilder     = commandContextBuilder;
     m_PrintedCommandPermissions = new List <IPermissionRegistration>();
 }
 public CommandSender(IHandlerResolver handlerResolver,
                      IEventPublisher eventPublisher,
                      IEventFactory eventFactory,
                      IEventStore eventStore,
                      ICommandStore commandStore,
                      IOptions <EventOptions> options = null)
 {
     _eventPublisher      = eventPublisher;
     _eventFactory        = eventFactory;
     _eventStore          = eventStore;
     _commandStore        = commandStore;
     _handlerResolver     = handlerResolver;
     _supportTransactions = options?.Value.SupportTransactions ?? false;
 }
Example #16
0
        public void SetUp()
        {
            Directory.CreateDirectory(_path);
            _config = new EngineConfiguration();
            _config.JournalPath = _path;
            _config.MaxEntriesPerJournalSegment = 10;
            _store = new FileCommandStore(_config);
            _store.Initialize();

            var writer = _store.CreateJournalWriter(0);
            for (ulong i = 0; i < 30; i++)
            {
                writer.Write(new JournalEntry<Command>(i + 1, new TestCommandWithoutResult()));
            }
            writer.Close();
        }
Example #17
0
 public DomainCommandSender(IHandlerResolver handlerResolver,
                            IEventPublisher eventPublisher,
                            IEventFactory eventFactory,
                            IAggregateStore aggregateStore,
                            ICommandStore commandStore,
                            IEventStore eventStore,
                            IOptions <Options> options)
 {
     _handlerResolver = handlerResolver;
     _eventPublisher  = eventPublisher;
     _eventFactory    = eventFactory;
     _aggregateStore  = aggregateStore;
     _commandStore    = commandStore;
     _eventStore      = eventStore;
     _options         = options.Value;
 }
Example #18
0
        public void SetUp()
        {
            Directory.CreateDirectory(_path);
            _config             = new EngineConfiguration();
            _config.JournalPath = _path;
            _config.MaxEntriesPerJournalSegment = 10;
            _store = new FileCommandStore(_config);
            _store.Initialize();

            var writer = _store.CreateJournalWriter(0);

            for (ulong i = 0; i < 30; i++)
            {
                writer.Write(new JournalEntry <Command>(i + 1, new TestCommandWithoutResult()));
            }
            writer.Close();
        }
Example #19
0
        public CommandHelp(
            IRuntime runtime,
            ICommandStore commandStore,
            IServiceProvider serviceProvider,
            IPermissionRegistry permissionRegistry,
            ICommandPermissionBuilder commandPermissionBuilder,
            ICommandContextBuilder commandContextBuilder,
            IOpenModStringLocalizer stringLocalizer) : base(serviceProvider)
        {
            // get global permission checker instead of scoped
            m_PermissionChecker = runtime.Host !.Services.GetRequiredService <IPermissionChecker>();

            m_CommandStore             = commandStore;
            m_PermissionRegistry       = permissionRegistry;
            m_CommandPermissionBuilder = commandPermissionBuilder;
            m_CommandContextBuilder    = commandContextBuilder;
            m_StringLocalizer          = stringLocalizer;
        }
Example #20
0
        private static void InitializeENode(
            bool useMockCommandStore = false,
            bool useMockEventStore = false,
            bool useMockPublishedVersionStore = false,
            bool useMockDomainEventPublisher = false,
            bool useMockApplicationMessagePublisher = false,
            bool useMockPublishableExceptionPublisher = false)
        {
            var setting = new ConfigurationSetting(ConfigurationManager.AppSettings["connectionString"]);
            var assemblies = new[]
            {
                Assembly.GetExecutingAssembly()
            };

            _enodeConfiguration = ECommonConfiguration
                .Create()
                .UseAutofac()
                .RegisterCommonComponents()
                .UseLog4Net()
                .UseJsonNet()
                .RegisterUnhandledExceptionHandler()
                .CreateENode(setting)
                .RegisterENodeComponents()
                .UseCommandStore(useMockCommandStore)
                .UseEventStore(useMockEventStore)
                .UsePublishedVersionStore(useMockPublishedVersionStore)
                .RegisterBusinessComponents(assemblies)
                .InitializeBusinessAssemblies(assemblies)
                .UseEQueue(useMockDomainEventPublisher, useMockApplicationMessagePublisher, useMockPublishableExceptionPublisher)
                .StartEQueue();

            _commandService = ObjectContainer.Resolve<ICommandService>();
            _memoryCache = ObjectContainer.Resolve<IMemoryCache>();
            _commandStore = ObjectContainer.Resolve<ICommandStore>();
            _eventStore = ObjectContainer.Resolve<IEventStore>();
            _publishedVersionStore = ObjectContainer.Resolve<IPublishedVersionStore>();
            _domainEventPublisher = ObjectContainer.Resolve<IMessagePublisher<DomainEventStreamMessage>>();
            _applicationMessagePublisher = ObjectContainer.Resolve<IMessagePublisher<IApplicationMessage>>();
            _publishableExceptionPublisher = ObjectContainer.Resolve<IMessagePublisher<IPublishableException>>();
            _logger = ObjectContainer.Resolve<ILoggerFactory>().Create(typeof(BaseTest));
            _logger.Info("ENode initialized.");
        }
Example #21
0
        private static void InitializeENode(
            bool useMockCommandStore                  = false,
            bool useMockEventStore                    = false,
            bool useMockPublishedVersionStore         = false,
            bool useMockDomainEventPublisher          = false,
            bool useMockApplicationMessagePublisher   = false,
            bool useMockPublishableExceptionPublisher = false)
        {
            var setting    = new ConfigurationSetting(ConfigurationManager.AppSettings["connectionString"]);
            var assemblies = new[]
            {
                Assembly.GetExecutingAssembly()
            };

            _enodeConfiguration = ECommonConfiguration
                                  .Create()
                                  .UseAutofac()
                                  .RegisterCommonComponents()
                                  .UseLog4Net()
                                  .UseJsonNet()
                                  .RegisterUnhandledExceptionHandler()
                                  .CreateENode(setting)
                                  .RegisterENodeComponents()
                                  .UseCommandStore(useMockCommandStore)
                                  .UseEventStore(useMockEventStore)
                                  .UsePublishedVersionStore(useMockPublishedVersionStore)
                                  .RegisterBusinessComponents(assemblies)
                                  .InitializeBusinessAssemblies(assemblies)
                                  .UseEQueue(useMockDomainEventPublisher, useMockApplicationMessagePublisher, useMockPublishableExceptionPublisher)
                                  .StartEQueue();

            _commandService                = ObjectContainer.Resolve <ICommandService>();
            _memoryCache                   = ObjectContainer.Resolve <IMemoryCache>();
            _commandStore                  = ObjectContainer.Resolve <ICommandStore>();
            _eventStore                    = ObjectContainer.Resolve <IEventStore>();
            _publishedVersionStore         = ObjectContainer.Resolve <IPublishedVersionStore>();
            _domainEventPublisher          = ObjectContainer.Resolve <IMessagePublisher <DomainEventStreamMessage> >();
            _applicationMessagePublisher   = ObjectContainer.Resolve <IMessagePublisher <IApplicationMessage> >();
            _publishableExceptionPublisher = ObjectContainer.Resolve <IMessagePublisher <IPublishableException> >();
            _logger = ObjectContainer.Resolve <ILoggerFactory>().Create(typeof(BaseTest));
            _logger.Info("ENode initialized.");
        }
Example #22
0
    public DayArchiverProcessManager(
        IColdStorage coldStorage,
        IArchivableDaysRepository archivableDaysRepository,
        ICommandStore commandStore,
        TimeSpan threshold,
        IEventStore eventStore,
        Func <Guid> idGenerator
        )
    {
        _commandStore = commandStore;
        _idGenerator  = idGenerator;

        When <DayScheduled>(async(e, m) =>
        {
            await archivableDaysRepository.Add(new ArchivableDay(e.DayId, e.Date));
        });

        When <CalendarDayStarted>(async(e, m) =>
        {
            var archivableDays = await archivableDaysRepository.FindAll(e.Date.Add(threshold));
            foreach (var day in archivableDays)
            {
                await SendCommand(day.Id, m.CorrelationId, m.CausationId);
            }
        });

        When <DayScheduleArchived>(async(e, m) =>
        {
            var streamName = StreamName.For <Day>(e.DayId);

            var events = await eventStore.LoadEvents(streamName);
            coldStorage.SaveAll(events);

            var lastVersion = await eventStore.GetLastVersion(streamName);

            if (lastVersion.HasValue)
            {
                await eventStore.TruncateStream(streamName, lastVersion.Value);
            }
        });
    }
        public DefaultCommandDispatcher(ILogger <DefaultCommandDispatcher> logger,
                                        IServiceProvider serviceProvider,
                                        ICommandStore commandStore)
        {
            if (logger == null)
            {
                throw new ArgumentNullException(nameof(logger));
            }
            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }
            if (commandStore == null)
            {
                throw new ArgumentNullException(nameof(commandStore));
            }

            _logger          = logger;
            _serviceProvider = serviceProvider;
            _commandStore    = commandStore;
        }
Example #24
0
 public SingleCommandFactory(ICommandStore store, [ImportMany] IEnumerable<ICommand> commands)
 {
     foreach (var c in commands)
         store.AddCommand(c);
 }
 public MediatRCommandBus(IMediator mediator, ICommandStore commandStore)
 {
     this.mediator     = mediator;
     this.commandStore = commandStore;
 }
Example #26
0
 public PositionalCommandParser(ICommandStore commandStore)
 {
     _commandStoreRoot = commandStore;
 }
Example #27
0
 public void Init()
 {
     _config = EngineConfiguration.Create().ForIsolatedTest().ForImmutability();
     _commandStore = new InMemoryCommandStore(_config);
     _commandStore.Initialize();
 }
Example #28
0
 public StoreCommands(ICommandStore store)
 {
     this.store = store;
 }
 public IdempotentBehaviour(ICommandStore commandStore)
 {
     _commandStore = commandStore ?? throw new ArgumentNullException(nameof(commandStore));
 }
Example #30
0
 public void SetCommand(ICommandStore com)
 {
     command = com;
 }
Example #31
0
 private void AssertJournalEntriesAreSequential(ICommandStore storage)
 {
     ulong expected = 1;
     Console.WriteLine("JournalEntry Ids:");
     foreach (var journalEntry in storage.CommandEntries())
     {
         Console.WriteLine(journalEntry.Id);
         Assert.AreEqual(expected, journalEntry.Id);
         expected++;
     }
 }
Example #32
0
 public ModelLoader(EngineConfiguration config, ICommandStore commandStore = null, ISnapshotStore snapshotStore = null)
 {
     _commandStore = commandStore ?? config.CreateCommandStore();
     _snapshotStore = snapshotStore ?? config.CreateSnapshotStore();
 }
Example #33
0
 public static JournalAppender Create(ulong nextEntryId, ICommandStore store)
 {
     return(Create(nextEntryId, store.CreateJournalWriter(nextEntryId)));
 }
 public CommandPermissionBuilder(ICommandStore commandStore)
 {
     m_CommandStore = commandStore;
 }
Example #35
0
 public WebSearchCommandFactory(ICommandStore store)
 {
     store.AddCommand(new WebSearchCommand("msdn", "http://msdn.microsoft.com/", "http://social.msdn.microsoft.com/Search/en-US?query=%s"));
     store.AddCommand(new WebSearchCommand("StackOverflow", "http://stackoverflow.com/", "http://www.google.com/#hl=en&q=%s+site%3Astackoverflow.com"));
     store.AddCommand(new WebSearchCommand("Wikipedia", "http://en.wikipedia.org/", "http://en.wikipedia.org/wiki/Special:Search/%s"));
     store.AddCommand(new WebSearchCommand("?", "http://bing.com/", "http://www.bing.com/search?q=%s"));
     store.AddCommand(new WebSearchCommand("bing", "http://bing.com/", "http://www.bing.com/search?q=%s"));
     store.AddCommand(new WebSearchCommand("AcronymFinder", "http://www.acronymfinder.com/", "http://www.acronymfinder.com/%s.html"));
     store.AddCommand(new WebSearchCommand("Microsoft Mail", "https://mail.microsoft.com", "https://mail.microsoft.com"));
     store.AddCommand(new WebSearchCommand("gmail", "https://gmail.com", "https://gmail.com"));
 }
Example #36
0
 public void Init()
 {
     _config       = new EngineConfiguration().ForIsolatedTest().ForImmutability();
     _commandStore = new InMemoryCommandStore(_config);
     _commandStore.Initialize();
 }
Example #37
0
 private void AssertJournalEntriesAreSequential(ICommandStore storage)
 {
     ulong expected = 1;
     foreach (var journalEntry in storage.CommandEntries())
     {
         Assert.AreEqual(expected, journalEntry.Id);
         expected++;
     }
 }
Example #38
0
 public ModelLoader(EngineConfiguration config, ICommandStore commandStore = null, ISnapshotStore snapshotStore = null)
 {
     _commandStore  = commandStore ?? config.CreateCommandStore();
     _snapshotStore = snapshotStore ?? config.CreateSnapshotStore();
 }
Example #39
0
 public Help(ICommandStore commandStore, ICommandProcessor commandProcessor)
 {
     _commandStore     = commandStore;
     _commandProcessor = commandProcessor;
 }
Example #40
0
 public Learn(ICommandStore commandStore) => _commandStore = commandStore;