Exemplo n.º 1
0
        private void PublishEvent()
        {
            IMyEvent eventMessage;

            switch (nextEventToPublish)
            {
            case 0:
                eventMessage       = this.Bus.CreateInstance <IMyEvent>();
                nextEventToPublish = 1;
                break;

            case 1:
                eventMessage       = new EventMessage();
                nextEventToPublish = 2;
                break;

            default:
                eventMessage       = new AnotherEventMessage();
                nextEventToPublish = 0;
                break;
            }

            eventMessage.EventId  = Guid.NewGuid();
            eventMessage.Time     = DateTime.Now.Second > -1 ? (DateTime?)DateTime.Now : null;
            eventMessage.Duration = TimeSpan.FromSeconds(99999D);

            this.Bus.Publish(eventMessage);

            Console.WriteLine("Published event with Id {0}.", eventMessage.EventId);
            Console.WriteLine("==========================================================================");
        }
Exemplo n.º 2
0
    static async Task Start(IEndpointInstance endpointInstance)
    {
        Console.WriteLine("Press '1' to publish IEvent");
        Console.WriteLine("Press '2' to publish EventMessage");
        Console.WriteLine("Press '3' to publish AnotherEventMessage");
        Console.WriteLine("Press any other key to exit");
        #region PublishLoop
        while (true)
        {
            var key = Console.ReadKey();
            Console.WriteLine();

            var eventId = Guid.NewGuid();
            switch (key.Key)
            {
            case ConsoleKey.D1:
                await endpointInstance.Publish <IMyEvent>(m =>
                {
                    m.EventId  = eventId;
                    m.Time     = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null;
                    m.Duration = TimeSpan.FromSeconds(99999D);
                })
                .ConfigureAwait(false);

                Console.WriteLine($"Published IMyEvent with Id {eventId}.");
                continue;

            case ConsoleKey.D2:
                var eventMessage = new EventMessage
                {
                    EventId  = eventId,
                    Time     = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null,
                    Duration = TimeSpan.FromSeconds(99999D)
                };
                await endpointInstance.Publish(eventMessage)
                .ConfigureAwait(false);

                Console.WriteLine($"Published EventMessage with Id {eventId}.");
                continue;

            case ConsoleKey.D3:
                var anotherEventMessage = new AnotherEventMessage
                {
                    EventId  = eventId,
                    Time     = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null,
                    Duration = TimeSpan.FromSeconds(99999D)
                };
                await endpointInstance.Publish(anotherEventMessage)
                .ConfigureAwait(false);

                Console.WriteLine($"Published AnotherEventMessage with Id {eventId}.");
                continue;

            default:
                return;
            }
        }
        #endregion
    }
Exemplo n.º 3
0
    static async Task Start(IBusSession busSession)
    {
        Console.WriteLine("Press '1' to publish IEvent");
        Console.WriteLine("Press '2' to publish EventMessage");
        Console.WriteLine("Press '3' to publish AnotherEventMessage");
        Console.WriteLine("Press 'Enter' to publish a message.To exit, Ctrl + C");
        #region PublishLoop
        while (true)
        {
            ConsoleKeyInfo key = Console.ReadKey();
            Console.WriteLine();

            Guid eventId = Guid.NewGuid();
            switch (key.Key)
            {
            case ConsoleKey.D1:
                await busSession.Publish <IMyEvent>(m =>
                {
                    m.EventId  = eventId;
                    m.Time     = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null;
                    m.Duration = TimeSpan.FromSeconds(99999D);
                });

                Console.WriteLine("Published IMyEvent with Id {0}.", eventId);
                continue;

            case ConsoleKey.D2:
                EventMessage eventMessage = new EventMessage
                {
                    EventId  = eventId,
                    Time     = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null,
                    Duration = TimeSpan.FromSeconds(99999D)
                };
                await busSession.Publish(eventMessage);

                Console.WriteLine("Published EventMessage with Id {0}.", eventId);
                continue;

            case ConsoleKey.D3:
                AnotherEventMessage anotherEventMessage = new AnotherEventMessage
                {
                    EventId  = eventId,
                    Time     = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null,
                    Duration = TimeSpan.FromSeconds(99999D)
                };
                await busSession.Publish(anotherEventMessage);

                Console.WriteLine("Published AnotherEventMessage with Id {0}.", eventId);
                continue;

            default:
                return;
            }
        }
        #endregion
    }
Exemplo n.º 4
0
    static void Start(IBus bus)
    {
        Console.WriteLine("Press '1' to publish IEvent");
        Console.WriteLine("Press '2' to publish EventMessage");
        Console.WriteLine("Press '3' to publish AnotherEventMessage");
        Console.WriteLine("Press any other key to exit");
        #region PublishLoop
        while (true)
        {
            var key = Console.ReadKey();
            Console.WriteLine();

            var eventId  = Guid.NewGuid();
            var time     = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null;
            var duration = TimeSpan.FromSeconds(99999D);
            switch (key.Key)
            {
            case ConsoleKey.D1:
                bus.Publish <IMyEvent>(m =>
                {
                    m.EventId  = eventId;
                    m.Time     = time;
                    m.Duration = duration;
                });
                Console.WriteLine($"Published IMyEvent with Id {eventId}.");
                continue;

            case ConsoleKey.D2:
                var eventMessage = new EventMessage
                {
                    EventId  = eventId,
                    Time     = time,
                    Duration = duration
                };
                bus.Publish(eventMessage);
                Console.WriteLine($"Published EventMessage with Id {eventId}.");
                continue;

            case ConsoleKey.D3:
                var anotherEventMessage = new AnotherEventMessage
                {
                    EventId  = eventId,
                    Time     = time,
                    Duration = duration
                };
                bus.Publish(anotherEventMessage);
                Console.WriteLine($"Published AnotherEventMessage with Id {eventId}.");
                continue;

            default:
                return;
            }
        }
        #endregion
    }
Exemplo n.º 5
0
    static void Start(IBusSession busSession)
    {
        Console.WriteLine("Press '1' to publish IEvent");
        Console.WriteLine("Press '2' to publish EventMessage");
        Console.WriteLine("Press '3' to publish AnotherEventMessage");
        Console.WriteLine("Press 'Enter' to publish a message.To exit, Ctrl + C");
        #region PublishLoop
        while (true)
        {
            ConsoleKeyInfo key = Console.ReadKey();
            Console.WriteLine();

            Guid eventId = Guid.NewGuid();
            switch (key.Key)
            {
                case ConsoleKey.D1:
                    busSession.Publish<IMyEvent>(m =>
                    {
                        m.EventId = eventId;
                        m.Time = DateTime.Now.Second > 30 ? (DateTime?) DateTime.Now : null;
                        m.Duration = TimeSpan.FromSeconds(99999D);
                    });
                    Console.WriteLine("Published IMyEvent with Id {0}.", eventId);
                    continue;
                case ConsoleKey.D2:
                    EventMessage eventMessage = new EventMessage
                    {
                        EventId = eventId,
                        Time = DateTime.Now.Second > 30 ? (DateTime?) DateTime.Now : null,
                        Duration = TimeSpan.FromSeconds(99999D)
                    };
                    busSession.Publish(eventMessage);
                    Console.WriteLine("Published EventMessage with Id {0}.", eventId);
                    continue;
                case ConsoleKey.D3:
                    AnotherEventMessage anotherEventMessage = new AnotherEventMessage
                    {
                        EventId = eventId,
                        Time = DateTime.Now.Second > 30 ? (DateTime?) DateTime.Now : null,
                        Duration = TimeSpan.FromSeconds(99999D)
                    };
                    busSession.Publish(anotherEventMessage);
                    Console.WriteLine("Published AnotherEventMessage with Id {0}.", eventId);
                    continue;
                default:
                    return;
            }
        }
        #endregion
    }
Exemplo n.º 6
0
    static void Start(IBus bus)
    {
        Console.WriteLine("Press '1' to publish IEvent");
        Console.WriteLine("Press '2' to publish EventMessage");
        Console.WriteLine("Press '3' to publish AnotherEventMessage");
        Console.WriteLine("Press any key other key to exit");
        #region PublishLoop
        while (true)
        {
            var key = Console.ReadKey();
            Console.WriteLine();

            var eventId = Guid.NewGuid();
            switch (key.Key)
            {
                case ConsoleKey.D1:
                    bus.Publish<IMyEvent>(m =>
                    {
                        m.EventId = eventId;
                        m.Time = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null;
                        m.Duration = TimeSpan.FromSeconds(99999D);
                    });
                    Console.WriteLine($"Published IMyEvent with Id {eventId}.");
                    continue;
                case ConsoleKey.D2:
                    var eventMessage = new EventMessage
                    {
                        EventId = eventId,
                        Time = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null,
                        Duration = TimeSpan.FromSeconds(99999D)
                    };
                    bus.Publish(eventMessage);
                    Console.WriteLine($"Published EventMessage with Id {eventId}.");
                    continue;
                case ConsoleKey.D3:
                    var anotherEventMessage = new AnotherEventMessage
                    {
                        EventId = eventId,
                        Time = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null,
                        Duration = TimeSpan.FromSeconds(99999D)
                    };
                    bus.Publish(anotherEventMessage);
                    Console.WriteLine($"Published AnotherEventMessage with Id {eventId}.");
                    continue;
                default:
                    return;
            }
        }
        #endregion
    }
Exemplo n.º 7
0
    static void Start(IBus bus)
    {
        Console.WriteLine("This will publish IEvent, EventMessage, and AnotherEventMessage alternately.");
        Console.WriteLine("Press 'Enter' to publish a message.To exit, Ctrl + C");
        #region PublishLoop
        var nextEventToPublish = 0;
        while (Console.ReadLine() != null)
        {
            var eventId = Guid.NewGuid();
            switch (nextEventToPublish)
            {
            case 0:
                bus.Publish <IMyEvent>(m =>
                {
                    m.EventId  = eventId;
                    m.Time     = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null;
                    m.Duration = TimeSpan.FromSeconds(99999D);
                });
                nextEventToPublish = 1;
                break;

            case 1:
                var eventMessage = new EventMessage
                {
                    EventId  = eventId,
                    Time     = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null,
                    Duration = TimeSpan.FromSeconds(99999D)
                };
                bus.Publish(eventMessage);
                nextEventToPublish = 2;
                break;

            default:
                var anotherEventMessage = new AnotherEventMessage
                {
                    EventId  = eventId,
                    Time     = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null,
                    Duration = TimeSpan.FromSeconds(99999D)
                };
                bus.Publish(anotherEventMessage);
                nextEventToPublish = 0;
                break;
            }

            Console.WriteLine("Published event with Id {0}.", eventId);

            Console.WriteLine("==========================================================================");
        }
        #endregion
    }
Exemplo n.º 8
0
    static void Start(IBus bus)
    {
        Console.WriteLine("This will publish IEvent, EventMessage, and AnotherEventMessage alternately.");
        Console.WriteLine("Press 'Enter' to publish a message.To exit, Ctrl + C");
        #region PublishLoop
        int nextEventToPublish = 0;
        while (Console.ReadLine() != null)
        {
            Guid eventId = Guid.NewGuid();
            switch (nextEventToPublish)
            {
                case 0:
                    bus.Publish<IMyEvent>(m =>
                    {
                        m.EventId = eventId;
                        m.Time = DateTime.Now.Second > 30 ? (DateTime?) DateTime.Now : null;
                        m.Duration = TimeSpan.FromSeconds(99999D);
                    });
                    nextEventToPublish = 1;
                    break;
                case 1:
                    EventMessage eventMessage = new EventMessage
                    {
                        EventId = eventId,
                        Time = DateTime.Now.Second > 30 ? (DateTime?) DateTime.Now : null,
                        Duration = TimeSpan.FromSeconds(99999D)
                    };
                    bus.Publish(eventMessage);
                    nextEventToPublish = 2;
                    break;
                default:
                    AnotherEventMessage anotherEventMessage = new AnotherEventMessage
                    {
                        EventId = eventId,
                        Time = DateTime.Now.Second > 30 ? (DateTime?) DateTime.Now : null,
                        Duration = TimeSpan.FromSeconds(99999D)
                    };
                    bus.Publish(anotherEventMessage);
                    nextEventToPublish = 0;
                    break;
            }

            Console.WriteLine("Published event with Id {0}.", eventId);
        }
        #endregion
    }
Exemplo n.º 9
0
        public void Start()
        {
            Console.WriteLine("This will publish IEvent, EventMessage, and AnotherEventMessage alternately.");
            Console.WriteLine("Press 'Enter' to publish a message.To exit, Ctrl + C");

            var nextEventToPublish = 0;

            while (Console.ReadLine() != null)
            {
                IMyEvent eventMessage;

                switch (nextEventToPublish)
                {
                case 0:
                    eventMessage       = Bus.CreateInstance <IMyEvent>();
                    nextEventToPublish = 1;
                    break;

                case 1:
                    eventMessage       = new EventMessage();
                    nextEventToPublish = 2;
                    break;

                default:
                    eventMessage       = new AnotherEventMessage();
                    nextEventToPublish = 0;
                    break;
                }

                eventMessage.EventId  = Guid.NewGuid();
                eventMessage.Time     = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null;
                eventMessage.Duration = TimeSpan.FromSeconds(99999D);

                Bus.Publish(eventMessage);

                // Do a custom check
                MyCustomCheck myCheck = new MyCustomCheck();

                Console.WriteLine("Published event with Id {0}.", eventMessage.EventId);
                Console.WriteLine("==========================================================================");
            }
        }
Exemplo n.º 10
0
        public void Start()
        {
            Console.WriteLine("This will publish IEvent, EventMessage, and AnotherEventMessage alternately.");
            Console.WriteLine("Press 'Enter' to publish a message.To exit, Ctrl + C");

            var nextEventToPublish = 0;
            while (Console.ReadLine() != null)
            {
                IMyEvent eventMessage;

                switch (nextEventToPublish)
                {
                    case 0 :
                        eventMessage = Bus.CreateInstance<IMyEvent>();
                        nextEventToPublish = 1;
                        break;
                    case 1 :
                        eventMessage = new EventMessage();
                        nextEventToPublish = 2;
                        break;
                    default:
                        eventMessage = new AnotherEventMessage();
                        nextEventToPublish = 0;
                        break;
                }

                eventMessage.EventId = Guid.NewGuid();
                eventMessage.Time = DateTime.Now.Second > 30 ? (DateTime?)DateTime.Now : null;
                eventMessage.Duration = TimeSpan.FromSeconds(99999D);

                Bus.Publish(eventMessage);

                // Do a custom check
                MyCustomCheck myCheck = new MyCustomCheck();

                Console.WriteLine("Published event with Id {0}.", eventMessage.EventId);
                Console.WriteLine("==========================================================================");
            }
        }
Exemplo n.º 11
0
    static async Task Start(IEndpointInstance endpointInstance)
    {
        Console.WriteLine("Press '1' to publish IEvent");
        Console.WriteLine("Press '2' to publish EventMessage");
        Console.WriteLine("Press '3' to publish AnotherEventMessage");
        Console.WriteLine("Press any other key to exit");
        #region PublishLoop
        while (true)
        {
            ConsoleKeyInfo key = Console.ReadKey();
            Console.WriteLine();

            Guid eventId = Guid.NewGuid();
            switch (key.Key)
            {
                case ConsoleKey.D1:
                    await endpointInstance.Publish<IMyEvent>(m =>
                    {
                        m.EventId = eventId;
                        m.Time = DateTime.Now.Second > 30 ? (DateTime?) DateTime.Now : null;
                        m.Duration = TimeSpan.FromSeconds(99999D);
                    });
                    Console.WriteLine("Published IMyEvent with Id {0}.", eventId);
                    continue;
                case ConsoleKey.D2:
                    EventMessage eventMessage = new EventMessage
                    {
                        EventId = eventId,
                        Time = DateTime.Now.Second > 30 ? (DateTime?) DateTime.Now : null,
                        Duration = TimeSpan.FromSeconds(99999D)
                    };
                    await endpointInstance.Publish(eventMessage);
                    Console.WriteLine("Published EventMessage with Id {0}.", eventId);
                    continue;
                case ConsoleKey.D3:
                    AnotherEventMessage anotherEventMessage = new AnotherEventMessage
                    {
                        EventId = eventId,
                        Time = DateTime.Now.Second > 30 ? (DateTime?) DateTime.Now : null,
                        Duration = TimeSpan.FromSeconds(99999D)
                    };
                    await endpointInstance.Publish(anotherEventMessage);
                    Console.WriteLine("Published AnotherEventMessage with Id {0}.", eventId);
                    continue;
                default:
                    return;
            }
        }
        #endregion
    }