public bool CheckConvert(string InArgument, Type InType, out string OutErrorMessage) { string str; DebugHelper.Assert((InArgument != null) && InType.IsEnum); OutErrorMessage = string.Empty; string[] names = Enum.GetNames(InType); for (int i = 0; i < names.Length; i++) { if (names[i].Equals(InArgument, StringComparison.CurrentCultureIgnoreCase)) { return(true); } } if (ArgumentDescriptionDefault.CheckConvertUtil(InArgument, typeof(int), out str)) { int num2 = System.Convert.ToInt32(InArgument); if (string.IsNullOrEmpty(Enum.GetName(InType, num2))) { OutErrorMessage = string.Format("不能将\"{0}\"转换到{1}的任何值.", InArgument, InType.Name); } return(false); } OutErrorMessage = string.Format("不能将\"{0}\"转换为任何有效属性.", InArgument); return(false); }
public bool CheckConvert(string InArgument, Type InType, out string OutErrorMessage) { DebugHelper.Assert(InArgument != null && InType.get_IsEnum()); OutErrorMessage = string.Empty; string[] names = Enum.GetNames(InType); for (int i = 0; i < names.Length; i++) { if (names[i].Equals(InArgument, 1)) { return(true); } } string text; if (ArgumentDescriptionDefault.CheckConvertUtil(InArgument, typeof(int), out text)) { int num = System.Convert.ToInt32(InArgument); string name = Enum.GetName(InType, num); if (string.IsNullOrEmpty(name)) { OutErrorMessage = string.Format("不能将\"{0}\"转换到{1}的任何值.", InArgument, InType.get_Name()); } return(false); } OutErrorMessage = string.Format("不能将\"{0}\"转换为任何有效属性.", InArgument); return(false); }
public static int StringToEnum(Type InType, string InText) { string text; if (ArgumentDescriptionDefault.CheckConvertUtil(InText, typeof(int), out text)) { return(System.Convert.ToInt32(InText)); } return(System.Convert.ToInt32(Enum.Parse(InType, InText, true))); }
public object Convert(string InArgument, Type InType) { string str; if (ArgumentDescriptionDefault.CheckConvertUtil(InArgument, typeof(int), out str)) { int num = System.Convert.ToInt32(InArgument); return(Enum.ToObject(InType, num)); } return(Enum.Parse(InType, InArgument, true)); }
public List <string> FilteredCandinates(Type InType, string InArgument) { string str; if (ArgumentDescriptionDefault.CheckConvertUtil(InArgument, typeof(int), out str)) { int num = System.Convert.ToInt32(InArgument); string name = Enum.GetName(InType, num); return(this.FilteredCandinatesInner(InType, name)); } return(this.FilteredCandinatesInner(InType, InArgument)); }
public string GetValue(Type InType, string InArgument) { DebugHelper.Assert(InArgument != null); string[] names = Enum.GetNames(InType); for (int i = 0; i < names.Length; i++) { if (names[i].Equals(InArgument, 1)) { return(names[i]); } } string text; if (ArgumentDescriptionDefault.CheckConvertUtil(InArgument, typeof(int), out text)) { int num = System.Convert.ToInt32(InArgument); return(Enum.GetName(InType, num)); } return(string.Empty); }
public bool CheckConvert(string InArgument, Type InType, out string OutErrorMessage) { return(ArgumentDescriptionDefault.CheckConvertUtil(InArgument, InType, out OutErrorMessage)); }