public EnvironmentViewModel(IEnvironment environment,
                                    IConnectivity connectivity,
                                    IPowerManager powerManager)
        {
            this.environment = environment;

            this.networkReach = connectivity
                                .WhenAnyValue(x => x.Reach)
                                .Select(x => x.ToString())
                                .ObserveOn(RxApp.MainThreadScheduler)
                                .ToProperty(this, x => x.NetworkReach);

            this.networkAccess = connectivity
                                 .WhenAnyValue(x => x.Access)
                                 .Select(x => x.ToString())
                                 .ObserveOn(RxApp.MainThreadScheduler)
                                 .ToProperty(this, x => x.NetworkAccess);

            this.powerStatus = powerManager
                               .WhenAnyValue(x => x.Status)
                               .Select(x => x.ToString())
                               .ObserveOn(RxApp.MainThreadScheduler)
                               .ToProperty(this, x => x.PowerStatus);

            this.batteryPercentage = powerManager
                                     .WhenAnyValue(x => x.BatteryLevel)
                                     .ObserveOn(RxApp.MainThreadScheduler)
                                     .ToProperty(this, x => x.BatteryPercentage);
        }
Example #2
0
        public EnvironmentViewModel(IEnvironment environment,
                                    IConnectivity connectivity,
                                    IPowerManager powerManager)
        {
            this.environment = environment;

            connectivity
            .WhenAnyValue(x => x.Reach)
            .Select(x => x.ToString())
            .ToPropertyEx(this, x => x.NetworkReach)
            .DisposedBy(this.DeactivateWith);

            connectivity
            .WhenAnyValue(x => x.Access)
            .Select(x => x.ToString())
            .ToPropertyEx(this, x => x.NetworkAccess)
            .DisposedBy(this.DeactivateWith);

            connectivity
            .WhenAnyValue(x => x.CellularCarrier)
            .ToPropertyEx(this, x => x.CellularCarrier)
            .DisposedBy(this.DeactivateWith);

            powerManager
            .WhenAnyValue(x => x.IsEnergySavingEnabled)
            .ToPropertyEx(this, x => x.IsEnergySavingEnabled)
            .DisposedBy(this.DeactivateWith);

            powerManager
            .WhenAnyValue(x => x.Status)
            .Select(x => x.ToString())
            .ToPropertyEx(this, x => x.PowerStatus)
            .DisposedBy(this.DeactivateWith);

            powerManager
            .WhenAnyValue(x => x.BatteryLevel)
            .ToPropertyEx(this, x => x.BatteryPercentage)
            .DisposedBy(this.DeactivateWith);
        }