Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
internal class Program
{
private static void Main(string[] args)
{
var registry = new SubscriberRegistry();
registry.Register<GreetingCommand, GreetingCommandHandler>();
var tinyIoCContainer = new TinyIoCContainer();
tinyIoCContainer.Register<IHandleRequests<GreetingCommand>, GreetingCommandHandler>();
var commandStore =
new MySqlCommandStore(
new MySqlCommandStoreConfiguration("Server=localhost;Uid=root;Pwd=root;Database=BrighterTests",
"commands"));
tinyIoCContainer.Register<IAmACommandStore>(commandStore);
tinyIoCContainer.Register<IAmACommandStoreAsync>(commandStore);
var builder = CommandProcessorBuilder.With()
.Handlers(new HandlerConfiguration(
subscriberRegistry: registry,
handlerFactory: new TinyIocHandlerFactory(tinyIoCContainer)
))
.DefaultPolicy()
.NoTaskQueues()
.RequestContextFactory(new InMemoryRequestContextFactory());
var commandProcessor = builder.Build();
var greetingCommand = new GreetingCommand("Derek");
commandProcessor.Send(greetingCommand);
var retrievedCommand = commandStore.Get<GreetingCommand>(greetingCommand.Id);
Console.WriteLine(string.Format("Command retrieved from store: {0}", JsonConvert.SerializeObject(retrievedCommand)));
Console.ReadLine();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.