📄 horizontalalignconverter.cs
字号:
using System;
using System.ComponentModel;
using System.Globalization;
namespace System.Web.UI.WebControls
{
/// <summary>
/// Summary description for HorizontalAlignConverter.
/// </summary>
public class HorizontalAlignConverter : EnumConverter
{
private static string[] stringValues;
static HorizontalAlignConverter()
{
HorizontalAlignConverter.stringValues = new String[5];
HorizontalAlignConverter.stringValues[0] = "NotSet";
HorizontalAlignConverter.stringValues[1] = "Left";
HorizontalAlignConverter.stringValues[2] = "Center";
HorizontalAlignConverter.stringValues[3] = "Right";
HorizontalAlignConverter.stringValues[4] = "Justify";
}
public HorizontalAlignConverter() : base(typeof(HorizontalAlign))
{
}
public virtual bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(String))
return true;
return this.CanConvertFrom(context, sourceType);
}
public virtual bool CanConvertTo(ITypeDescriptorContext context, Type sourceType)
{
if (sourceType == typeof(String))
return true;
return this.CanConvertTo(context, sourceType);
}
public virtual object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
{
string local0;
string local1;
if (value == null)
return null;
if (value as String != null)
{
local0 = ((String) value).Trim();
if (local0.Length == 0)
return 0;
// <{ class ILEngineer::Ops::MSIL::Leave }>;
if ((local1 = local0) != null)
{
local1 = System.String.IsInterned(local1);
if (local1 != "NotSet")
{
if (local1 == "Left")
{
// goto i1;
}
if (local1 == "Center")
{
// goto i2;
}
if (local1 == "Right")
{
// goto i3;
}
if (local1 == "Justify")
{
// goto i4;
}
}
else
{
return 0;
i1: return 1;
i2: return 2;
i3: return 3;
i4: return 4;
}
}
}
return this.ConvertFrom(context, culture, value);
}
public virtual object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
{
if (destinationType == typeof(String) && (Int32) value <= 4)
return HorizontalAlignConverter.stringValues[(Int32) value];
return this.ConvertTo(context, culture, value, destinationType);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -