Пример #1
0
        public BluetoothLeDeviceWrapperFactory(
            [NotNull] ILogger logger,
            [NotNull] IGattServicesProviderFactory providerFactory,
            [NotNull] IGattDeviceServicesResultWrapperFactory servicesFactory,
            [NotNull] Func <IGattServicesDictionary> gattServicesDictionaryFactory,
            [NotNull] IGattCharacteristicsResultWrapperFactory characteristicsFactory,
            [NotNull] Func <ISubject <BluetoothConnectionStatus> > connectionStatusChangedFactory,
            [NotNull] BluetoothLeDeviceWrapper.Factory factory)
        {
            Guard.ArgumentNotNull(logger,
                                  nameof(logger));
            Guard.ArgumentNotNull(providerFactory,
                                  nameof(providerFactory));
            Guard.ArgumentNotNull(servicesFactory,
                                  nameof(servicesFactory));
            Guard.ArgumentNotNull(gattServicesDictionaryFactory,
                                  nameof(gattServicesDictionaryFactory));
            Guard.ArgumentNotNull(characteristicsFactory,
                                  nameof(characteristicsFactory));
            Guard.ArgumentNotNull(connectionStatusChangedFactory,
                                  nameof(connectionStatusChangedFactory));
            Guard.ArgumentNotNull(factory,
                                  nameof(factory));

            _logger          = logger;
            _providerFactory = providerFactory;
            _servicesFactory = servicesFactory;
            _gattServicesDictionaryFactory  = gattServicesDictionaryFactory;
            _characteristicsFactory         = characteristicsFactory;
            _connectionStatusChangedFactory = connectionStatusChangedFactory;
            _factory = factory;
        }
        public BluetoothLeDeviceWrapper(
            [JetBrains.Annotations.NotNull] ILogger logger,
            [JetBrains.Annotations.NotNull] IScheduler scheduler,
            [JetBrains.Annotations.NotNull] IGattServicesProviderFactory providerFactory,
            [JetBrains.Annotations.NotNull] IGattDeviceServicesResultWrapperFactory servicesFactory,
            [JetBrains.Annotations.NotNull] IGattServicesDictionary gattServicesDictionary,
            [JetBrains.Annotations.NotNull] ISubject <BluetoothConnectionStatus> connectionStatusChanged,
            [JetBrains.Annotations.NotNull] BluetoothLEDevice device)
        {
            Guard.ArgumentNotNull(logger,
                                  nameof(logger));
            Guard.ArgumentNotNull(scheduler,
                                  nameof(scheduler));
            Guard.ArgumentNotNull(providerFactory,
                                  nameof(providerFactory));
            Guard.ArgumentNotNull(servicesFactory,
                                  nameof(servicesFactory));
            Guard.ArgumentNotNull(gattServicesDictionary,
                                  nameof(gattServicesDictionary));
            Guard.ArgumentNotNull(connectionStatusChanged,
                                  nameof(connectionStatusChanged));
            Guard.ArgumentNotNull(device,
                                  nameof(device));

            _logger                  = logger;
            _servicesFactory         = servicesFactory;
            _provider                = providerFactory.Create(this);
            _gattServicesDictionary  = gattServicesDictionary;
            _connectionStatusChanged = connectionStatusChanged;
            _device                  = device;

            var statusChanged =
                Observable.FromEventPattern <object> (_device,
                                                      "ConnectionStatusChanged");

            _subscriberConnectionStatus = statusChanged.SubscribeOn(scheduler)
                                          .Subscribe(OnConnectionStatusChanged);
        }