当前位置: 首页>>代码示例>>C#>>正文


C# IActivity.GetCustomDataValue方法代码示例

本文整理汇总了C#中IActivity.GetCustomDataValue方法的典型用法代码示例。如果您正苦于以下问题:C# IActivity.GetCustomDataValue方法的具体用法?C# IActivity.GetCustomDataValue怎么用?C# IActivity.GetCustomDataValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IActivity的用法示例。


在下文中一共展示了IActivity.GetCustomDataValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CustomFields

        private static string CustomFields(IActivity activity, ActivityInfo activityInfoInstance, string field)
        {
            string fieldValue = "";

            ICustomDataFieldObjectType type = CustomDataFieldDefinitions.StandardObjectType(typeof(IActivity));

            foreach (ICustomDataFieldDefinition definition in
                CalculatedFields.GetLogBook().CustomDataFieldDefinitions)
            {
                if (definition.Name.ToUpper() == field && definition.ObjectType == type)
                {
                    if (activity.GetCustomDataValue(definition) == null)
                    {
                        fieldValue = "null";
                    }
                    else
                    {
                        if (definition.DataType.Id == CustomDataFieldDefinitions.StandardDataTypes.NumberDataTypeId)
                        {
                            fieldValue = Double.Parse(activity.GetCustomDataValue(definition).ToString()).ToString(CultureInfo.InvariantCulture.NumberFormat);
                        }
                        else if (definition.DataType.Id == CustomDataFieldDefinitions.StandardDataTypes.TextDataTypeId)
                        {
                            fieldValue = activity.GetCustomDataValue(definition).ToString().Escape();
                        }
                        else if (definition.DataType.Id == CustomDataFieldDefinitions.StandardDataTypes.TimeSpanDataTypeId)
                        {
                            fieldValue = TimeSpan.Parse(activity.GetCustomDataValue(definition).ToString()).TotalSeconds.ToString(CultureInfo.InvariantCulture.NumberFormat);
                        }
                    }
                }
            }

            return fieldValue;
        }
开发者ID:gerhardol,项目名称:calculatedfields,代码行数:35,代码来源:Evaluator.cs

示例2: boGetExported

        public bool boGetExported(IActivity activity)
        {
            if (activity != null)
            {
            #if !ST_2_1
                int? ExportedCustData = (int?)(activity.GetCustomDataValue(FunbeatExportedField) as double?);
            #else
                int? ExportedCustData = null;
            #endif

                // Upgrade from old to new method of marking an activity to be exported
                if (ExportedCustData == null)
                {
                    // Check if metadata string exists and update the cust data field
                    bool boExported = (activity.Metadata.Source.IndexOf("Funbeated") >= 0);
            #if !ST_2_1
                    if (boExported)
                        activity.SetCustomDataValue(FunbeatExportedField, (double?)1.0);
                    else
                        activity.SetCustomDataValue(FunbeatExportedField, (double?)0.0);
            #endif
                    return boExported;
                }
                else
                {
                    return (ExportedCustData != 0);
                }
            }
            else
                return false;
        }
开发者ID:TheProjecter,项目名称:st2funbeat,代码行数:31,代码来源:FitnessDataHandler.cs

示例3: AthleteFields


//.........这里部分代码省略.........
                    fieldValue = athleteEntry.SystolicBloodPressure.ToString(CultureInfo.InvariantCulture.NumberFormat);
                    break;
                case "ATHLETEINJURED":
                    fieldValue = athleteEntry.Injured.ToString();
                    break;
                case "ATHLETEINJUREDTEXT":
                    fieldValue = "\"" + athleteEntry.InjuredText + "\"";
                    break;
                case "ATHLETEMAXHR":
                    fieldValue = athleteEntry.MaximumHeartRatePerMinute.ToString(CultureInfo.InvariantCulture.NumberFormat);
                    break;
                case "ATHLETEMISSEDWORKOUT":
                    fieldValue = athleteEntry.MissedWorkout.ToString();
                    break;
                case "ATHLETEMISSEDWORKOUTTEXT":
                    fieldValue = "\"" + athleteEntry.MissedWorkoutText + "\"";
                    break;
                case "ATHLETEMOOD":
                    fieldValue = athleteEntry.Mood.ToString(CultureInfo.InvariantCulture.NumberFormat);
                    break;
                case "ATHLETERESTHR":
                    fieldValue = athleteEntry.RestingHeartRatePerMinute.ToString(CultureInfo.InvariantCulture.NumberFormat);
                    break;
                case "ATHLETESICK":
                    fieldValue = athleteEntry.Sick.ToString();
                    break;
                case "ATHLETESICKTEXT":
                    fieldValue = "\"" + athleteEntry.SickText.Escape() + "\"";
                    break;
                case "ATHLETESKINFOLD":
                    fieldValue = athleteEntry.Skinfold.ToString(CultureInfo.InvariantCulture.NumberFormat);
                    break;
                case "ATHLETESLEEPHOURS":
                    fieldValue = athleteEntry.SleepHours.ToString(CultureInfo.InvariantCulture.NumberFormat);
                    break;
                case "ATHLETESLEEPQUALITY":
                    fieldValue = "\"" + athleteEntry.SleepQuality.ToString(CultureInfo.InvariantCulture.NumberFormat) + "\"";
                    break;
                case "ATHLETEWEIGHT":
                    fieldValue = athleteEntry.WeightKilograms.ToString(CultureInfo.InvariantCulture.NumberFormat);
                    break;

                case "ATHLETEHEIGHT":
                    fieldValue = CalculatedFields.GetLogBook().Athlete.HeightCentimeters.ToString(CultureInfo.InvariantCulture.NumberFormat);
                    break;
                case "ATHLETESEX":
                    fieldValue = "\"" + CalculatedFields.GetLogBook().Athlete.Sex.ToString() + "\"";
                    break;
                case "ATHLETEBIRTHDATE":
                    fieldValue = "\"" + CalculatedFields.GetLogBook().Athlete.DateOfBirth.ToShortDateString() + "\"";
                    break;
                case "ATHLETEAGE":
                    DateTime now = activity.StartTime.ToUniversalTime() + activity.TimeZoneUtcOffset;
                    DateTime birth = CalculatedFields.GetLogBook().Athlete.DateOfBirth;

                    int years = now.Year - birth.Year;

                    if (now.Month < birth.Month || (now.Month == birth.Month && now.Day < birth.Day))
                    {
                        --years;
                    }

                    fieldValue = years.ToString(CultureInfo.InvariantCulture.NumberFormat);
                    break;
            }

            ICustomDataFieldObjectType type = CustomDataFieldDefinitions.StandardObjectType(typeof(IAthleteInfoEntry));

            foreach (ICustomDataFieldDefinition definition in
                CalculatedFields.GetLogBook().CustomDataFieldDefinitions)
            {
                if (definition.Name.ToUpper() == field && definition.ObjectType == type)
                {
                    if (athleteEntry.GetCustomDataValue(definition) != null)
                    {
                        if (athleteEntry.GetCustomDataValue(definition) == null)
                        {
                            fieldValue = "null";
                        }
                        else
                        {
                            if (definition.DataType.Id == CustomDataFieldDefinitions.StandardDataTypes.NumberDataTypeId)
                            {
                                fieldValue = Double.Parse(athleteEntry.GetCustomDataValue(definition).ToString()).ToString(CultureInfo.InvariantCulture.NumberFormat);
                            }
                            else if (definition.DataType.Id == CustomDataFieldDefinitions.StandardDataTypes.TextDataTypeId)
                            {
                                fieldValue = athleteEntry.GetCustomDataValue(definition).ToString().Escape();
                            }
                            else if (definition.DataType.Id == CustomDataFieldDefinitions.StandardDataTypes.TimeSpanDataTypeId)
                            {
                                fieldValue = TimeSpan.Parse(activity.GetCustomDataValue(definition).ToString()).TotalSeconds.ToString(CultureInfo.InvariantCulture.NumberFormat);
                            }
                        }
                    }
                }
            }

            return fieldValue;
        }
开发者ID:gerhardol,项目名称:calculatedfields,代码行数:101,代码来源:Evaluator.cs

示例4: GetCustomFieldsData

 public void GetCustomFieldsData(IActivity activity, 
     out int? RPE,
     out double? TE,
     out int? Repetitions,
     out int? Sets)
 {
     if (activity != null)
     {
         RPE = (int?)(activity.GetCustomDataValue(RPEField) as double?);
         TE = activity.GetCustomDataValue(TEField) as double?;
         Repetitions = (int?)(activity.GetCustomDataValue(RepetitionsField) as double?);
         Sets = (int?)(activity.GetCustomDataValue(SetsField) as double?);
     }
     else
     {
         RPE = null;
         TE = null;
         Repetitions = null;
         Sets = null;
     }
 }
开发者ID:TheProjecter,项目名称:st2funbeat,代码行数:21,代码来源:FitnessDataHandler.cs


注:本文中的IActivity.GetCustomDataValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。