Esempio n. 1
0
        public static EnumTypePropertyDescription FromEnumTypeName(string enumTypeName)
        {
            enumTypeName.CheckStringIsNullOrEmpty("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)
		{
			enumTypeName.CheckStringIsNullOrEmpty("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;
		}
Esempio n. 3
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);
        }
Esempio n. 4
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);
        }
		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;
		}