Пример #1
0
        private static void SubscribeClient(string clientName)
        {
            var c = clients.Single(i => i.Name == clientName);

            if (c != null)
            {
                capstan.Subscribe(c);
            }
        }
Пример #2
0
        private static void Setup()
        {
            capstan =
                Builder <StringMessage, string> .New()
                .AddRoute("Error", (input, dependencies) => new ErrorEvent(input))
                .AddRoute("ReturnToMe", (input, dependencies) => new BounceEvent(input))
                .AddRoute("TellAll", (input, dependencies) => new ToAllEvent(input))
                .AddRoute("TellOthers", (input, dependencies) => new TellOthersEvent(input))
                .AddRoute("Void", (input, dependencies) => new VoidEvent(input))
                .AddRoute("TellMeMuch", (input, dependencies) => new ChattyEventFactory().Create(input, dependencies)) //Create an instance of the factory, or use static method Create.
                .RegisterDependencies(container =>
            {
                //Remember: using Unity;
                container.RegisterType <IEnterpriseBusinessDependency, EnterpriseBusinessDependency>(new TransientLifetimeManager());
            })
                .RegisterActivist((dependencies) => new PeoplePoker <StringMessage, string>()) //Register Activist that pokes random person on a timer
                .SetBroadcaster(dependencies => new Broadcaster <StringMessage, string>())
                .SetErrorManager(dependencies => new FeaturedErrorManager())
                .Build();

            capstan.Subscribe(new LoggerClient(1337, "Logger"));
        }