|
图标类型转换:提供String2Icon、Icon2Int及Icon2String。
eg:ExtAspNet.Icon icon = ExtAspNet.IconConvertor.String2Icon("Basket", true);
//ExtAspNet\Business\Enums\Icon.cs
/// <summary>
/// 图标类型转换
/// </summary>
public class IconConvertor
{
/// <summary>
/// String To Icon
/// </summary>
/// <param name="text"></param>
/// <param name="ignoreCase"></param>
/// <returns></returns>
public static Icon String2Icon(string text, bool ignoreCase)
{
if (Enum.IsDefined(typeof(Icon), text))
{
return (Icon)Enum.Parse(typeof(Icon), text, ignoreCase);
}
else
{
return Icon.None;
}
}
/// <summary>
/// Icon To Int
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public static int Icon2Int(Icon type)
{
return (int)type;
}
/// <summary>
/// Int To Icon
/// </summary>
/// <param name="n"></param>
/// <returns></returns>
public static Icon Int2Icon(int n)
{
if (Enum.IsDefined(typeof(Icon), n))
return (Icon)n;
else
throw new Exception(n + " is not defined");
}
/// <summary>
/// Icon To String
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public static String Icon2String(Icon type)
{
return type.ToString();
}
}
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
|