當前位置: 首頁>>代碼示例>>C#>>正文


C# EnumConverter.IsValid方法代碼示例

本文整理匯總了C#中System.ComponentModel.EnumConverter.IsValid方法的典型用法代碼示例。如果您正苦於以下問題:C# EnumConverter.IsValid方法的具體用法?C# EnumConverter.IsValid怎麽用?C# EnumConverter.IsValid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ComponentModel.EnumConverter的用法示例。


在下文中一共展示了EnumConverter.IsValid方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: DeserializeBoxSettings

			private void DeserializeBoxSettings(AnnotationBox boxSettings, XmlElement boxSettingsNode)
			{
				string font = boxSettingsNode.GetAttribute("font");
				string color = boxSettingsNode.GetAttribute("color");
				string italics = boxSettingsNode.GetAttribute("italics");
				string bold = boxSettingsNode.GetAttribute("bold");
				string numberOfLines = boxSettingsNode.GetAttribute("number-of-lines");
				string truncation = boxSettingsNode.GetAttribute("truncation");
				string justification = boxSettingsNode.GetAttribute("justification");
				string verticalAlignment = boxSettingsNode.GetAttribute("vertical-alignment");
				string fitWidth = boxSettingsNode.GetAttribute("fit-width");
				string alwaysVisible = boxSettingsNode.GetAttribute("always-visible");

				if (!String.IsNullOrEmpty(font))
					boxSettings.Font = font;
				if (!String.IsNullOrEmpty(color))
					boxSettings.Color = color;
				if (!String.IsNullOrEmpty(italics))
					boxSettings.Italics = (String.Compare("true", italics, true) == 0);
				if (!String.IsNullOrEmpty(bold))
					boxSettings.Bold = (String.Compare("true", bold, true) == 0);
				if (!String.IsNullOrEmpty(numberOfLines))
				{
					byte result;
					if (!byte.TryParse(numberOfLines, System.Globalization.NumberStyles.Integer, System.Globalization.CultureInfo.InvariantCulture, out result))
						result = 1;

					boxSettings.NumberOfLines = result;
				}

				if (!String.IsNullOrEmpty(fitWidth))
					boxSettings.FitWidth = (String.Compare("true", fitWidth) == 0);

				if (!String.IsNullOrEmpty(alwaysVisible))
					boxSettings.AlwaysVisible = (String.Compare("true", alwaysVisible, true) == 0);

				if (!String.IsNullOrEmpty(truncation))
				{
					AnnotationBox.TruncationBehaviour fromString = boxSettings.Truncation;
					EnumConverter converter = new EnumConverter(typeof(AnnotationBox.TruncationBehaviour));
					if (converter.IsValid(truncation))
						boxSettings.Truncation = (AnnotationBox.TruncationBehaviour)converter.ConvertFromString(truncation);
				}

				if (!String.IsNullOrEmpty(justification))
				{
					AnnotationBox.JustificationBehaviour fromString = boxSettings.Justification;
					EnumConverter converter = new EnumConverter(typeof(AnnotationBox.JustificationBehaviour));
					if (converter.IsValid(justification))
						boxSettings.Justification = (AnnotationBox.JustificationBehaviour)converter.ConvertFromString(justification);
				}

				if (!String.IsNullOrEmpty(verticalAlignment))
				{
					AnnotationBox.VerticalAlignmentBehaviour fromString = boxSettings.VerticalAlignment;
					EnumConverter converter = new EnumConverter(typeof(AnnotationBox.VerticalAlignmentBehaviour));
					if (converter.IsValid(verticalAlignment))
						boxSettings.VerticalAlignment = (AnnotationBox.VerticalAlignmentBehaviour)converter.ConvertFromString(verticalAlignment);
				}

				XmlElement configurationSettings = (XmlElement)boxSettingsNode.SelectSingleNode("configuration-settings");
				if (configurationSettings != null)
				{
					string showLabel = configurationSettings.GetAttribute("show-label");
					string showLabelIfEmpty = configurationSettings.GetAttribute("show-label-if-empty");
					if (!String.IsNullOrEmpty(showLabel))
						boxSettings.ConfigurationOptions.ShowLabel = (String.Compare("true", showLabel, true) == 0);
					if (!String.IsNullOrEmpty(showLabelIfEmpty))
						boxSettings.ConfigurationOptions.ShowLabelIfValueEmpty = (String.Compare("true", showLabelIfEmpty, true) == 0);
				}
			}
開發者ID:nhannd,項目名稱:Xian,代碼行數:71,代碼來源:AnnotationLayoutStore.cs

示例2: IsValid

 public override bool IsValid(ITypeDescriptorContext context, object value)
 {
     if (value != null)
     {
         if (value.GetType() == this.m_Type)
         {
             return true;
         }
         if (value.GetType() != typeof(string))
         {
             return false;
         }
         char[] separator = new char[] { '\n' };
         string[] strArray = ((string) value).Split(separator);
         if (strArray.Length < 2)
         {
             return false;
         }
         EnumConverter converter = new EnumConverter(typeof(WrapMode));
         if (!converter.IsValid(strArray[0]))
         {
             return false;
         }
         if (!converter.IsValid(strArray[1]))
         {
             return false;
         }
         for (int i = 2; i < strArray.Length; i++)
         {
             char[] chArray2 = new char[] { ',' };
             string[] strArray2 = strArray[i].Split(chArray2);
             if (strArray2.Length != 4)
             {
                 return false;
             }
             foreach (string str in strArray2)
             {
                 float num3;
                 if (!float.TryParse(str, NumberStyles.Float, CultureInfo.InvariantCulture, out num3))
                 {
                     return false;
                 }
             }
         }
     }
     return true;
 }
開發者ID:CarlosHBC,項目名稱:UnityDecompiled,代碼行數:47,代碼來源:AnimationCurveTypeConverter.cs


注:本文中的System.ComponentModel.EnumConverter.IsValid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。