📄 unitconverter.cs
字号:
using System;
using System.ComponentModel;
using System.Globalization;
namespace System.Web.UI.WebControls
{
/// <summary>
/// Summary description for UnitConverter.
/// </summary>
public class UnitConverter : TypeConverter
{
public UnitConverter() : base()
{
}
public virtual bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(String))
return true;
return this.CanConvertFrom(context, sourceType);
}
public virtual object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
string local0;
if (value == null)
return null;
if (value as String != null)
{
local0 = ((String) value).Trim();
if (local0.Length == 0)
return System.Web.UI.WebControls.Unit.Empty;
if (culture != null)
return System.Web.UI.WebControls.Unit.Parse(local0, culture);
return System.Web.UI.WebControls.Unit.Parse(local0);
}
return this.ConvertFrom(context, culture, value);
}
public virtual object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
Unit local0;
if (destinationType == typeof(String))
{
if (value != null)
{
local0 = (Unit) value;
if (!(local0.IsEmpty))
goto i1;
}
return System.String.Empty;
i1: local0 = (Unit) value;
return local0.ToString(culture);
}
return this.ConvertTo(context, culture, value, destinationType);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -