System.Globalization.CultureInfo.GetFormat C# (CSharp) Méthode

GetFormat() public méthode

public GetFormat ( Type formatType ) : object
formatType Type
Résultat object
		public virtual object GetFormat( Type formatType )
		{
			object format = null;

			if ( formatType == typeof(NumberFormatInfo) )
				format = NumberFormat;
			else if ( formatType == typeof(DateTimeFormatInfo) )
				format = DateTimeFormat;
			
			return format;
		}
		

Usage Example

Exemple #1
0
		public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
		{
			var str = value as string;
			if (str != null)
			{
				string text = str.Trim();
				try
				{
					object result;
					if (AllowHex && text[0] == '#')
					{
						result = FromString(text.Substring(1), 16);
						return result;
					}
					if ((AllowHex && text.StartsWith("0x", StringComparison.OrdinalIgnoreCase)) || text.StartsWith("&h", StringComparison.OrdinalIgnoreCase))
					{
						result = FromString(text.Substring(2), 16);
						return result;
					}
					culture = culture ?? CultureInfo.CurrentCulture;
					var formatInfo = (NumberFormatInfo)culture.GetFormat(typeof(NumberFormatInfo));
					result = FromString(text, formatInfo);
					return result;
				}
				catch (Exception innerException)
				{
					throw new Exception(text, innerException);
				}
			}
			return base.ConvertFrom(context, culture, value);
		}
All Usage Examples Of System.Globalization.CultureInfo::GetFormat