1
0
mirror of synced 2024-11-05 02:59:16 +00:00
Tapeti/Test/Program.cs

73 lines
2.4 KiB
C#
Raw Normal View History

using System;
using SimpleInjector;
using Tapeti;
2017-02-12 20:43:30 +00:00
using Tapeti.DataAnnotations;
using Tapeti.Flow;
using Tapeti.SimpleInjector;
using System.Threading;
2018-12-19 20:41:19 +00:00
using Tapeti.Flow.SQL;
namespace Test
{
internal class Program
{
private static void Main()
{
// TODO logging
2018-06-12 08:12:52 +00:00
var container = new Container();
2016-12-07 09:19:16 +00:00
container.Register<MarcoEmitter>();
container.Register<Visualizer>();
container.Register<ILogger, Tapeti.Default.ConsoleLogger>();
2016-12-07 09:19:16 +00:00
var config = new TapetiConfig(new SimpleInjectorDependencyResolver(container))
2018-12-19 20:41:19 +00:00
//.WithFlowSqlRepository("Server=localhost;Database=TapetiTest;Integrated Security=true")
.WithFlow()
2017-02-12 20:43:30 +00:00
.WithDataAnnotations()
2016-12-07 09:19:16 +00:00
.RegisterAllControllers()
.Build();
using (var connection = new TapetiConnection(config)
{
Params = new TapetiAppSettingsConnectionParams()
})
{
var flowStore = container.GetInstance<IFlowStore>();
var flowStore2 = container.GetInstance<IFlowStore>();
Console.WriteLine("IFlowHandler is singleton = " + (flowStore == flowStore2));
connection.Connected += (sender, e) => {
Console.WriteLine("Event Connected");
};
connection.Disconnected += (sender, e) => {
Console.WriteLine("Event Disconnected");
};
connection.Reconnected += (sender, e) => {
Console.WriteLine("Event Reconnected");
};
Console.WriteLine("Subscribing...");
var subscriber = connection.Subscribe(false).Result;
Console.WriteLine("Consuming...");
subscriber.Resume().Wait();
Console.WriteLine("Done!");
connection.GetPublisher().Publish(new FlowEndController.PingMessage());
//container.GetInstance<IFlowStarter>().Start<MarcoController, bool>(c => c.StartFlow, true);
container.GetInstance<IFlowStarter>().Start<MarcoController>(c => c.TestParallelRequest);
Thread.Sleep(1000);
var emitter = container.GetInstance<MarcoEmitter>();
emitter.Run().Wait();
}
}
}
}