public static EnumTypePropertyDescription FromEnumTypeName(string enumTypeName)
		{
			if (string.IsNullOrEmpty(enumTypeName))
				throw new ArgumentNullException("enumTypeName");

			Type type = Type.GetType(enumTypeName);

			EnumTypePropertyDescription result = null;

			if (type != null)
			{
				EnumItemDescriptionList itemDespList = EnumItemDescriptionAttribute.GetDescriptionList(type);

				result = new EnumTypePropertyDescription();

				result.EnumTypeName = enumTypeName;

				foreach (EnumItemDescription itemDesp in itemDespList)
				{
					EnumItemPropertyDescription eipd = new EnumItemPropertyDescription();

					eipd.Value = itemDesp.ShortName.IsNotEmpty() ? itemDesp.ShortName : itemDesp.EnumValue.ToString();
					eipd.Text = itemDesp.Description.IsNotEmpty() ? itemDesp.Description : itemDesp.Name;

					result.Items.Add(eipd);
				}
			}

			return result;
		}
        public static EnumTypePropertyDescription FromEnumTypeName(string enumTypeName)
        {
            if (string.IsNullOrEmpty(enumTypeName))
            {
                throw new ArgumentNullException("enumTypeName");
            }

            Type type = Type.GetType(enumTypeName);

            EnumTypePropertyDescription result = null;

            if (type != null)
            {
                EnumItemDescriptionList itemDespList = EnumItemDescriptionAttribute.GetDescriptionList(type);

                result = new EnumTypePropertyDescription();

                result.EnumTypeName = enumTypeName;

                foreach (EnumItemDescription itemDesp in itemDespList)
                {
                    EnumItemPropertyDescription eipd = new EnumItemPropertyDescription();

                    eipd.Value = itemDesp.ShortName.IsNotEmpty() ? itemDesp.ShortName : itemDesp.EnumValue.ToString();
                    eipd.Text  = itemDesp.Description.IsNotEmpty() ? itemDesp.Description : itemDesp.Name;

                    result.Items.Add(eipd);
                }
            }

            return(result);
        }
		public override object Deserialize(IDictionary<string, object> dictionary, Type type, JavaScriptSerializer serializer)
		{
			EnumItemPropertyDescription desp = new EnumItemPropertyDescription();

			desp.Value = DictionaryHelper.GetValue(dictionary, "value", string.Empty);
			desp.Text = DictionaryHelper.GetValue(dictionary, "text", string.Empty);

			return desp;
		}
Ejemplo n.º 4
0
        public override object Deserialize(IDictionary <string, object> dictionary, Type type, JavaScriptSerializer serializer)
        {
            EnumItemPropertyDescription desp = new EnumItemPropertyDescription();

            desp.Value = DictionaryHelper.GetValue(dictionary, "value", string.Empty);
            desp.Text  = DictionaryHelper.GetValue(dictionary, "text", string.Empty);

            return(desp);
        }
Ejemplo n.º 5
0
        public override IDictionary <string, object> Serialize(object obj, JavaScriptSerializer serializer)
        {
            EnumItemPropertyDescription desp = (EnumItemPropertyDescription)obj;

            Dictionary <string, object> dictionary = new Dictionary <string, object>();

            dictionary.AddNonDefaultValue("value", desp.Value);
            dictionary.AddNonDefaultValue("text", desp.Text);

            return(dictionary);
        }