Files
Dec2017-Script-Dump/System/ComponentModel/StringConverter.cs
T
2026-06-04 11:42:34 +02:00

41 lines
2.0 KiB
C#

using System;
using System.Globalization;
namespace System.ComponentModel
{
/// <summary>Provides a type converter to convert string objects to and from other representations.</summary>
// Token: 0x020000C2 RID: 194
public class StringConverter : TypeConverter
{
/// <summary>Gets a value indicating whether this converter can convert an object in the given source type to a string using the specified 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="sourceType">A <see cref="T:System.Type" /> that represents the type you wish to convert from. </param>
// Token: 0x06000669 RID: 1641 RVA: 0x00010C90 File Offset: 0x0000EE90
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
return sourceType == typeof(string) || base.CanConvertFrom(context, sourceType);
}
/// <summary>Converts the specified value object to a <see cref="T:System.String" /> object.</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">The <see cref="T:System.Globalization.CultureInfo" /> to use. </param>
/// <param name="value">The <see cref="T:System.Object" /> to convert. </param>
/// <exception cref="T:System.NotSupportedException">The conversion could not be performed. </exception>
// Token: 0x0600066A RID: 1642 RVA: 0x00010CAC File Offset: 0x0000EEAC
public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
if (value == null)
{
return string.Empty;
}
if (value is string)
{
return (string)value;
}
return base.ConvertFrom(context, culture, value);
}
}
}