示例#1
0
        public BluetoothProfileActivator(IBluetoothService bluetoothService,
                                         IPersonalizationSettings personalizationSettings,
                                         ISchedulerProvider schedulerProvider,
                                         ILoggerFactory loggerFactory)
        {
            _bluetoothService        = bluetoothService;
            _personalizationSettings = personalizationSettings;
            _schedulerProvider       = schedulerProvider;
            _logger             = loggerFactory.CreateLogger(GetType());
            _bluetoothEventLoop = _schedulerProvider.CreateEventLoopScheduler("BluetoothActivator");
            _logger.Verbose("BluetoothProfileActivator.ctor();");

            _profileActivated = _bluetoothService.IdentitiesActivated(_bluetoothEventLoop)
                                .Retry()
                                .Repeat()
                                .Log(_logger, "IdentitiesActivated")
                                .Select(Translate)
                                .Publish();

            //HACK: Avoid work in the ctor. Can be smart here using SelectMany on the IsEnabled + Connecting when ProfileActivated is subscribed to. -LC
            if (_bluetoothService.IsSupported && IsEnabled)
            {
                _connection.Disposable = _profileActivated.Connect();
            }
        }
示例#2
0
 public AggregatingLogger(ILogger underlyingLogger, ISchedulerProvider schedulerProvider)
 {
     _underlyingLogger  = underlyingLogger;
     _workerScheduler   = schedulerProvider.CreateEventLoopScheduler("AggregatingLogger");
     _traceSubscription = _traceEvents
                          //Aggregate and Log asynchronously. Could alternatively use TaskPool or ThreadPool. Needs requirements and use-cases *Discussion point.
                          .ObserveOn(_workerScheduler)
                          //Make thread safe
                          .Synchronize()
                          //Split incoming traces into independent sequences based on the trace name (so I don't aggregate Auth calls with WebRequest calls for example)
                          .GroupBy(trace => trace.Name)
                          //Aggregate on the fly
                          .SelectMany(grp => grp.Scan(new TraceAggregator(), (agg, trace) => agg.Add(trace.Elapsed)))
                          //Log aggregate values as they happen
                          .Subscribe(aggregate => this.Debug("Call Count :'{0}'. Mean average execution time: '{1}'", aggregate.Count, aggregate.MeanAverage()));
 }
        public BluetoothProfileActivator(IBluetoothService bluetoothService,
            IPersonalizationSettings personalizationSettings,
            ISchedulerProvider schedulerProvider,
            ILoggerFactory loggerFactory)
        {
            _bluetoothService = bluetoothService;
            _personalizationSettings = personalizationSettings;
            _schedulerProvider = schedulerProvider;
            _logger = loggerFactory.CreateLogger(GetType());
            _bluetoothEventLoop = _schedulerProvider.CreateEventLoopScheduler("BluetoothActivator");
            _logger.Verbose("BluetoothProfileActivator.ctor();");

            _profileActivated = _bluetoothService.IdentitiesActivated(_bluetoothEventLoop)
                .Retry()
                .Repeat()
                .Log(_logger, "IdentitiesActivated")
                .Select(Translate)
                .Publish();

            //HACK: Avoid work in the ctor. Can be smart here using SelectMany on the IsEnabled + Connecting when ProfileActivated is subscribed to. -LC
            if (_bluetoothService.IsSupported && IsEnabled)
                _connection.Disposable = _profileActivated.Connect();
        }