Files
2026-06-04 11:42:34 +02:00

72 lines
3.6 KiB
C#

using System;
using System.ComponentModel.Design.Serialization;
using System.Globalization;
using System.Reflection;
namespace System.ComponentModel
{
/// <summary>Provides a type converter to convert <see cref="T:System.Decimal" /> objects to and from various other representations.</summary>
// Token: 0x0200006B RID: 107
public class DecimalConverter : BaseNumberConverter
{
/// <summary>Initializes a new instance of the <see cref="T:System.ComponentModel.DecimalConverter" /> class. </summary>
// Token: 0x060003EF RID: 1007 RVA: 0x0000C04C File Offset: 0x0000A24C
public DecimalConverter()
{
this.InnerType = typeof(decimal);
}
// Token: 0x1700010F RID: 271
// (get) Token: 0x060003F0 RID: 1008 RVA: 0x0000C064 File Offset: 0x0000A264
internal override bool SupportHex
{
get
{
return false;
}
}
/// <summary>Gets a value indicating whether this converter can convert an object to the given destination type using the context.</summary>
/// <returns>true if this converter can perform the conversion; otherwise, false.</returns>
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context. </param>
/// <param name="destinationType">A <see cref="T:System.Type" /> that represents the type you wish to convert to. </param>
// Token: 0x060003F1 RID: 1009 RVA: 0x0000C068 File Offset: 0x0000A268
public override bool CanConvertTo(ITypeDescriptorContext context, Type destinationType)
{
return destinationType == typeof(global::System.ComponentModel.Design.Serialization.InstanceDescriptor) || base.CanConvertTo(context, destinationType);
}
/// <summary>Converts the given value object to a <see cref="T:System.Decimal" /> using the arguments.</summary>
/// <returns>An <see cref="T:System.Object" /> that represents the converted value.</returns>
/// <param name="context">An <see cref="T:System.ComponentModel.ITypeDescriptorContext" /> that provides a format context. </param>
/// <param name="culture">An optional <see cref="T:System.Globalization.CultureInfo" />. If not supplied, the current culture is assumed. </param>
/// <param name="value">The <see cref="T:System.Object" /> to convert. </param>
/// <param name="destinationType">The <see cref="T:System.Type" /> to convert the value to. </param>
/// <exception cref="T:System.ArgumentNullException">The <paramref name="destinationType" /> is null. </exception>
/// <exception cref="T:System.NotSupportedException">The conversion cannot be performed. </exception>
// Token: 0x060003F2 RID: 1010 RVA: 0x0000C084 File Offset: 0x0000A284
public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(global::System.ComponentModel.Design.Serialization.InstanceDescriptor) && value is decimal)
{
decimal num = (decimal)value;
ConstructorInfo constructor = typeof(decimal).GetConstructor(new Type[] { typeof(int[]) });
return new global::System.ComponentModel.Design.Serialization.InstanceDescriptor(constructor, new object[] { decimal.GetBits(num) });
}
return base.ConvertTo(context, culture, value, destinationType);
}
// Token: 0x060003F3 RID: 1011 RVA: 0x0000C0F8 File Offset: 0x0000A2F8
internal override string ConvertToString(object value, NumberFormatInfo format)
{
return ((decimal)value).ToString("G", format);
}
// Token: 0x060003F4 RID: 1012 RVA: 0x0000C11C File Offset: 0x0000A31C
internal override object ConvertFromString(string value, NumberFormatInfo format)
{
return decimal.Parse(value, NumberStyles.Float, format);
}
}
}