示例#1
0
        protected override Task <List <Datum> > PollAsync(CancellationToken cancellationToken)
        {
            List <Datum> data = new List <Datum>();

            NSError error;
            HKWheelchairUseObject wheelChair = HealthStore.GetWheelchairUse(out error);

            if (error == null)
            {
                if (wheelChair.WheelchairUse == HKWheelchairUse.NotSet)
                {
                    data.Add(new WheelChairUseDatum(DateTimeOffset.Now, WheelChairUse.NotSet));
                }
                else if (wheelChair.WheelchairUse == HKWheelchairUse.No)
                {
                    data.Add(new WheelChairUseDatum(DateTimeOffset.Now, WheelChairUse.No));
                }
                else if (wheelChair.WheelchairUse == HKWheelchairUse.Yes)
                {
                    data.Add(new WheelChairUseDatum(DateTimeOffset.Now, WheelChairUse.Yes));
                }
                else
                {
                    throw new Exception("User has not provided -- or has not allowed access to -- their wheel chair use status.");
                }
            }
            else
            {
                throw new Exception("Error reading wheel chair use status:  " + error.Description);
            }

            return(Task.FromResult(data));
        }