Пример #1
0
        public IServiceRunner Build(Func <ITraceableRemoteApiMap, IApplicationRecorder, IRunnable> setupCore)
        {
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json")
                                .Build();

            // System recorder
            var systemRecorder = new SystemRecorder();

            systemRecorder.InterruptedWithMessage += SystemInterruptedHandler;

            // Application recorder
            var applicationRecorder = new ApplicationRecorder(
                systemRecorder,
                new MessagesCache(Int32.Parse(configuration["MESSAGE_CACHE"])));

            var traceableRemoteApiMapFactory = new BaseTraceableRemoteApiMapFactory(new BaseInstructionReceiverFactory(applicationRecorder), applicationRecorder);
            var map = traceableRemoteApiMapFactory.Create(configuration["IP_ADDRESS"]);

            _core = setupCore?.Invoke(map, applicationRecorder);

            return(this);
        }
Пример #2
0
        public Task Run()
        {
            _mainApplicationTask = new TaskCompletionSource <bool>();

            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json")
                                .Build();

            // System recorder
            var systemRecorder = new SystemRecorder();

            _systemMessageDispatcher = systemRecorder;
            _systemMessageDispatcher.InterruptedWithMessage += SystemInterruptedHandler;

            // Application recorder
            _applicationRecorder = new ApplicationRecorder(systemRecorder,
                                                           new MessagesCache(Int32.Parse(configuration["MESSAGE_CACHE"])));

            // Remote trace monitor
            var remoteTraceMonitor = new RemoteTraceMonitor(new ConsoleAbstraction()
                                                            , Int32.Parse(configuration["MONITOR_LINES"]),
                                                            bool.Parse(configuration["SHOW_DEBUG_MESSAGES"]),
                                                            systemRecorder,
                                                            systemRecorder);

            remoteTraceMonitor.Start();
            var remoteTraceMonitorСonsistent = new RemoteTraceMonitorСonsistent(remoteTraceMonitor);

            var remoteOperatorFactory        = new BaseMonitoredRemoteOperatorFactory(new BaseInstructionSenderFactory(_applicationRecorder), remoteTraceMonitorСonsistent, _applicationRecorder, _applicationRecorder);
            var traceableRemoteApiMapFactory = new BaseTraceableRemoteApiMapFactory(new BaseInstructionReceiverFactory(_applicationRecorder), _applicationRecorder);

            var apiOperatorFactory = new ApiOperatorFactory(remoteOperatorFactory, traceableRemoteApiMapFactory, _applicationRecorder);

            apiOperatorFactory.Create(configuration["IP_ADDRESS"]);

            return(_mainApplicationTask.Task);
        }