private void SerializeValues(IDictionary <string, object> result) { if (MemberType != null && MemberType.GetNonNullableType().IsEnum) { var type = MemberType.GetNonNullableType(); var values = new List <IDictionary <string, object> >(); foreach (int value in Enum.GetValues(type)) { var obj = new Dictionary <string, object>(); var name = Enum.GetName(type, value); var member = type.GetMember(name).FirstOrDefault(); if (member != null) { var displayAttribute = member.GetCustomAttributes(typeof(DisplayAttribute), true) .OfType <DisplayAttribute>() .FirstOrDefault(); if (displayAttribute != null) { name = displayAttribute.GetName(); } } obj["value"] = value; obj["text"] = name; values.Add(obj); } result["values"] = values; } }