本文整理汇总了C#中CommandProcessor类的典型用法代码示例。如果您正苦于以下问题:C# CommandProcessor类的具体用法?C# CommandProcessor怎么用?C# CommandProcessor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CommandProcessor类属于命名空间,在下文中一共展示了CommandProcessor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterCommands
private static void RegisterCommands(Container container)
{
var eventDelegator = new EventBus();
var eventStore = new EventStore(eventDelegator);
var aggregateFactory = new AggregateFactory();
var commandProcessor = new CommandProcessor(aggregateFactory, eventStore);
container.RegisterSingleton<IProcessCommands>(() => commandProcessor);
}
示例2: CancelCommandGroup_CancelAGroup_AllCommandsInGroupAreCancelled
public void CancelCommandGroup_CancelAGroup_AllCommandsInGroupAreCancelled()
{
int[] commandsCanceled = {0};
var fakeFilterManager = A.Fake<IFilterManager>();
A.CallTo(() => fakeFilterManager.Process(A<CommandBase>.Ignored)).Returns(false);
var processor = new CommandProcessor(null, fakeFilterManager);
var commands = new[]
{
new TestCommand(CommandState.New, groupId: "GroupA"),
new TestCommand(CommandState.New, groupId: "GroupB"),
new TestCommand(CommandState.New, groupId: "GroupA"),
new TestCommand(CommandState.New, groupId: "GroupA"),
new TestCommand(CommandState.New, groupId: "GroupB"),
new TestCommand(CommandState.New, groupId: "GroupA"),
new TestCommand(CommandState.New, groupId: "GroupC"),
};
foreach (var command in commands)
{
command.RegisterForStateChange(Observer.Create<CommandState>(b =>
{
if (b == CommandState.Canceled)
{
commandsCanceled[0]++;
}
}));
processor.PublishCommand(command);
}
processor.CancelCommandGroup("GroupA");
Assert.AreEqual(4, commandsCanceled[0]);
}
示例3: start_the_application
public start_the_application(IBackgroundThread thread, ILoadPresentationModulesCommand command,
CommandProcessor processor)
{
this.thread = thread;
this.command = command;
this.processor = processor;
}
示例4: ExecuteQuery
private static void ExecuteQuery(CommandProcessor commandProcessor)
{
Console.WriteLine("Executing query");
var query = new SayHelloQuery("Dan");
commandProcessor.Execute(query).Wait();
Console.WriteLine(query.Result);
}
示例5: SetUp
public void SetUp()
{
repository = new Mock<Repository>();
next = new Mock<Processor<Event>>();
sut = new CommandProcessor(repository.Object, next.Object);
}
示例6: BuildRunner
public static IRunner BuildRunner(Action<IConfigurationHelper> configurator)
{
var configPlan = new ConfigurationPlan();
if (configurator != null)
{
configurator(configPlan);
}
configPlan.Validate();
var routingInfo = GetRoutingInfo(configPlan);
routingInfo.Validate();
var router = new CommandRouter(routingInfo);
var argsHelper = new ArgsHelper(configPlan.SwitchDelimiter);
var argsHelpProvider = new ArgsParameterHelpProvider(argsHelper);
var argsParameterBinder = new ArgsParameterBinder(argsHelper);
var helpProvider = new HelpProvider(router, argsHelpProvider);
var cmdProcessor = new CommandProcessor(router, configPlan.TypeInstantiationStrategy, argsParameterBinder);
return new RunnerInternal(helpProvider, cmdProcessor);
}
示例7: Main
public static void Main()
{
// we can create a singleton instance of the command processor. each execution can occur concurrently
// and has it's own state.
var processorSingleton = new CommandProcessor(DemoAPICommandProcessorConfiguration.Instance);
// command with return value - 1 transaction per command
int id = processorSingleton.Execute(new AddProductModel()
{
// ... properties ...
});
// command with no return value - 1 transaction per command
processorSingleton.Execute(new SetProductModelName()
{
// ... properties ...
});
processorSingleton.Execute(new AddProductReview()
{
ProductId = 316,
ReviewerName = "Joseph Daigle",
EmailAddress = "[email protected]",
Rating = 4,
Comments = "Meh",
});
}
示例8: SesService
public SesService(CommandProcessor processor)
{
if (processor == null)
{
throw new ArgumentNullException("processor");
}
_processor = processor;
}
示例9: SupportsQueryCommand
public void SupportsQueryCommand()
{
HomeState state = new HomeState();
state.CreateFurniture("sofa","room",new DateTime(2015,12,01));
Mock<TextWriter> writerMock = new Mock<TextWriter>();
CommandProcessor processor = new CommandProcessor(state, writerMock.Object);
string command = "query -date 01.12.2015";
processor.Process(command);
writerMock.Verify(w=>w.WriteLine(It.IsAny<string>()));
}
示例10: TestProcessCommand
static void TestProcessCommand()
{
SubscriptionClient subscriptionClient = SubscriptionClient.CreateFromConnectionString( serviceBusConnectionString, commandTopicPath, commandHandlerSubscription );
SubscriptionReceiver receiver = new SubscriptionReceiver( subscriptionClient );
ITextSerializer serializer = new JsonTextSerializer();
CommandProcessor orderCommandProcessor = new CommandProcessor( receiver, serializer );
orderCommandProcessor.Register( new OrderCommandHandler() );
orderCommandProcessor.Start();
}
示例11: ExecuteWithNullCommandThrowsArgumentNullException
public void ExecuteWithNullCommandThrowsArgumentNullException()
{
var serviceProviderMock = new Mock<IServiceProvider>(MockBehavior.Strict);
var sut = new CommandProcessor(serviceProviderMock.Object);
TestCommand command = null;
var ex = Assert.Throws<ArgumentNullException>(() => sut.Execute(command));
Assert.Equal("command", ex.ParamName);
}
示例12: Main
public static void Main()
{
// TODO: Add instance of the GameRenderingEngine and call that instance when creating the game engine
var brightSkin = new BrightSkin();
IOInterface userInterractor = new ConsoleInterface(brightSkin);
Scoreboard scoreboard = Scoreboard.GetInstance;
scoreboard.SetIOInterface(userInterractor);
GameBoard gameBoard = GameBoard.GetInstance;
CommandProcessor commandProcessor = new CommandProcessor(gameBoard, scoreboard, userInterractor, new CommandParser());
GameEngine engine = new GameEngine(commandProcessor, userInterractor, gameBoard);
engine.Play();
}
示例13: SetUp
public static void SetUp()
{
container = new TinyInversionOfControlContainer(new TinyIoCContainer());
commandProcessor = new CommandProcessor(container);
container.Register<IAmAUnitOfWorkFactory, UnitOfWorkFactory>().AsSingleton();
container.Register<IRepository<Meeting, MeetingDocument>, Repository<Meeting, MeetingDocument>>().AsMultiInstance();
container.Register<IIssueTickets, TicketIssuer>().AsMultiInstance();
container.Register<IScheduler, Scheduler>();
container.Register<IAmAnOverbookingPolicy, FiftyPercentOverbookingPolicy>();
container.Register<IIssueTickets, TicketIssuer>();
container.Register<IHandleRequests<ScheduleMeetingCommand>, ScheduleMeetingCommandHandler>("ScheduleMeetingCommandHandler");
}
示例14: VerifyTest
public void VerifyTest()
{
var cmd = new VerifyEmailAddressCommand
{
EmailAddress = Helper.GetSenderEmailAddress()
};
var cp = new CommandProcessor(_builder);
var resp = cp.Process(cmd, _parser);
Console.WriteLine(resp.Command + " : ID " + resp.RequestID);
}
示例15: SupportsRemoveRoomCommand
public void SupportsRemoveRoomCommand()
{
Mock<IHomeState> stateMock = new Mock<IHomeState>();
CommandProcessor processor = new CommandProcessor(stateMock.Object, Console.Out);
string command = "remove-room -date 12.01.2015 -room Bedroom -transfer dining";
processor.Process(command);
stateMock.Verify(a => a.RemoveRoom("Bedroom", "dining", new DateTime(2015, 01, 12)));
command = "remove-room -room Bedroom -date 12.01.2015";
processor.Process(command);
stateMock.Verify(a => a.RemoveRoom("Bedroom","dining",new DateTime(2015, 01, 12)));
command = "remove-room -room Bedroom -transfer dining";
processor.Process(command);
stateMock.Verify(a => a.RemoveRoom("Bedroom", "dining", It.IsAny<DateTime>()));
}