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

            NSError error;
            HKFitzpatrickSkinTypeObject skinType = HealthStore.GetFitzpatrickSkinType(out error);

            if (error == null)
            {
                if (skinType.SkinType == HKFitzpatrickSkinType.I)
                {
                    data.Add(new FitzpatrickSkinTypeDatum(DateTimeOffset.Now, FitzpatrickSkinType.TypeI));
                }
                else if (skinType.SkinType == HKFitzpatrickSkinType.II)
                {
                    data.Add(new FitzpatrickSkinTypeDatum(DateTimeOffset.Now, FitzpatrickSkinType.TypeII));
                }
                else if (skinType.SkinType == HKFitzpatrickSkinType.III)
                {
                    data.Add(new FitzpatrickSkinTypeDatum(DateTimeOffset.Now, FitzpatrickSkinType.TypeIII));
                }
                else if (skinType.SkinType == HKFitzpatrickSkinType.IV)
                {
                    data.Add(new FitzpatrickSkinTypeDatum(DateTimeOffset.Now, FitzpatrickSkinType.TypeIV));
                }
                else if (skinType.SkinType == HKFitzpatrickSkinType.V)
                {
                    data.Add(new FitzpatrickSkinTypeDatum(DateTimeOffset.Now, FitzpatrickSkinType.TypeV));
                }
                else if (skinType.SkinType == HKFitzpatrickSkinType.VI)
                {
                    data.Add(new FitzpatrickSkinTypeDatum(DateTimeOffset.Now, FitzpatrickSkinType.TypeVI));
                }
                else if (skinType.SkinType == HKFitzpatrickSkinType.NotSet)
                {
                    data.Add(new FitzpatrickSkinTypeDatum(DateTimeOffset.Now, FitzpatrickSkinType.NotSet));
                }
                else
                {
                    throw new Exception("User has not provided -- or has not allowed access to -- their fitzpatrick skin type.");
                }
            }
            else
            {
                throw new Exception("Error reading Fitzpatrick skin type:  " + error.Description);
            }

            return(Task.FromResult(data));
        }