/// <summary> /// Returns the associated string for a specific enum value. /// </summary> /// <param name="value">The enum value.</param> /// <returns>The string associated with the value, or <code>null</code> if not found.</returns> internal static string GetValue <TEnum>(TEnum value) { FieldInfo fi = typeof(MobileServiceFeatures).GetTypeInfo().GetDeclaredField(value.ToString()); string result = null; if (fi != null) { EnumValueAttribute eva = fi.GetCustomAttribute <EnumValueAttribute>(); if (eva != null) { result = eva.Value; } } return(result); }
static FeaturesHelper() { AllTelemetryFeatures = new List <Tuple <MobileServiceFeatures, string> >(); var features = (MobileServiceFeatures[])Enum.GetValues(typeof(MobileServiceFeatures)); foreach (var feature in features) { if (feature != MobileServiceFeatures.None) { AllTelemetryFeatures.Add(new Tuple <MobileServiceFeatures, string>(feature, EnumValueAttribute.GetValue(feature))); } } }