public PingAcknowledgeHandler(ISagasManager sagasManager, PingCommand pingCommand, IMessageBus messageBus, ILogger log)
 {
     _sagasManager = sagasManager ?? throw new ArgumentNullException(nameof(sagasManager));
     _pingCommand  = pingCommand ?? throw new ArgumentNullException(nameof(pingCommand));
     _messageBus   = messageBus ?? throw new ArgumentNullException(nameof(messageBus));
     this.log      = log ?? throw new ArgumentNullException(nameof(log));
 }
Beispiel #2
0
        //  private readonly IBusControl _masstransitBc;
        // private readonly IPublishEndpoint _publishEndpoint;
        //  private readonly ISendEndpointProvider _sendEndpoint;

        public Worker(ILogger <Worker> logger,
                      IMessageFactory messageFactory,
                      ISagasManager sagasManager,
                      IMessageBus messageBus,
                      IServiceProvider serviceProvider
                      // IBusControl busControl,
                      // IPublishEndpoint publishEndpoint,
                      // ISendEndpointProvider sendEndpoint
                      )
        {
            _logger          = logger ?? throw new ArgumentNullException(nameof(logger));
            _messageFactory  = messageFactory ?? throw new ArgumentNullException(nameof(messageFactory));
            _sagasManager    = sagasManager ?? throw new ArgumentNullException(nameof(sagasManager));
            _messageBus      = messageBus ?? throw new ArgumentNullException(nameof(messageBus));
            _serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider));
            // _masstransitBc = busControl ?? throw new ArgumentNullException(nameof(busControl));
            // _publishEndpoint = publishEndpoint ?? throw new ArgumentNullException(nameof(publishEndpoint));
            // _sendEndpoint = sendEndpoint ?? throw new ArgumentNullException(nameof(sendEndpoint));
        }
Beispiel #3
0
        static async Task Main(string[] args)
        {
            var builder = new ContainerBuilder();

            builder.RegisterModule <HubModule>();

            builder.RegisterType <CardNotificationHandler>();
            builder.RegisterType <CardCommand>();
            builder.RegisterType <FingerNotificationHandler>();
            builder.RegisterType <FingerCommand>();
            builder.RegisterType <BleNotificationHandler>();
            builder.RegisterType <BleCommand>();
            builder.RegisterType <PingCommand>();
            builder.RegisterType <PingAcknowledgeHandler>();

            var container = builder.Build();

            container.BeginLifetimeScope();
            var transportManager = container.Resolve <ITransportManager>();

            transportManager.TransportAdded += OnTransportAdded;
            var logger   = container.Resolve <ILogger>();
            var mfactory = container.Resolve <IMessageFactory>();

            SagaManager = container.Resolve <ISagasManager>();

            var messageBus = container.Resolve <IMessageBus>();

            Bus = messageBus;

            messageBus.Subscribe <CardNotificationHandler>("/dev/ttyS1");
            messageBus.Subscribe <BleNotificationHandler>("/dev/ttyS1");
            messageBus.Subscribe <FingerNotificationHandler>("/dev/ttyS1");
            messageBus.Subscribe <PingAcknowledgeHandler>("/dev/ttyS1");
            // var transport = new SerialPortTransport(mfactory, "/dev/ttyS1", true, logger);
            // transportManager.AddTransport(transport);



            while (true)
            {
                if (Console.ReadKey().KeyChar == 'q')
                {
                    break;
                }
            }


            //var type = typeof(IMessage);
            //var types = AppDomain.CurrentDomain.GetAssemblies()
            //    .SelectMany(s => s.GetTypes())
            //    .Where(p => type.IsAssignableFrom(p) && !p.IsAbstract && !p.IsInterface);
            //foreach(var item in types)
            //{
            //    Console.WriteLine(item.Name);
            //}

            //var factory = container.Resolve<IMessageFactory>();
            //var len = Message.IntToHighLow(2);
            //var body = new byte[] { 0x01, 0x00 };
            //var mm = new List<byte> { 0x02, 0xd5, 0xc7 };
            //mm.Add(Message.CalCheckSum(body));
            //mm.AddRange(Message.IntToHighLow(body.Length));
            //mm.AddRange(body);
            //factory.CreateMessage(mm.ToArray(), out IMessage message);
            //Console.WriteLine(message.GetType().Name);
            //var mtype = message.GetType().GetAttributeValue((MessageTypeAttribute m) => m.MessageType);
            //Console.WriteLine(BitConverter.ToString(new byte[] { mtype}));
            //string[] ports;
            //if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            //{
            //    ports = SerialPort.GetPortNames();
            //}else
            //{
            //    ports = PortHelpers.GetPortNames();
            //}

            //foreach (var item in ports)
            //{
            //    Console.WriteLine(item);
            //}
        }