本文整理汇总了C#中CommandProcessor.Execute方法的典型用法代码示例。如果您正苦于以下问题:C# CommandProcessor.Execute方法的具体用法?C# CommandProcessor.Execute怎么用?C# CommandProcessor.Execute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CommandProcessor
的用法示例。
在下文中一共展示了CommandProcessor.Execute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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",
});
}
示例2: ExecuteQuery
private static void ExecuteQuery(CommandProcessor commandProcessor)
{
Console.WriteLine("Executing query");
var query = new SayHelloQuery("Dan");
commandProcessor.Execute(query).Wait();
Console.WriteLine(query.Result);
}
示例3: 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);
}
示例4: ExecuteWithValidCommandExecutesCommand
public void ExecuteWithValidCommandExecutesCommand()
{
var serviceProviderMock = new Mock<IServiceProvider>(MockBehavior.Strict);
var commandHandlerMock = new Mock<ICommandHandler<TestCommand>>(MockBehavior.Strict);
var sut = new CommandProcessor(serviceProviderMock.Object);
var command = new TestCommand();
serviceProviderMock
.Setup(sp => sp.GetService(typeof(ICommandHandler<TestCommand>)))
.Returns(commandHandlerMock.Object);
commandHandlerMock.Setup(ch => ch.Handle(command));
sut.Execute(command);
serviceProviderMock.VerifyAll();
commandHandlerMock.VerifyAll();
}
示例5: ExecuteCommand
private static void ExecuteCommand(CommandProcessor commandProcessor)
{
Console.WriteLine("Executing command");
var command = new SayHelloCommand("Dan");
commandProcessor.Execute(command).Wait();
}