FineUI 官方论坛
标题:
图标类型转换:提供String2Icon、Icon2Int及Icon2String。
[打印本页]
作者:
redleaf
时间:
2012-3-29 13:30
标题:
图标类型转换:提供String2Icon、Icon2Int及Icon2String。
图标类型转换:提供String2Icon、Icon2Int及Icon2String。
eg:ExtAspNet.Icon icon = ExtAspNet.IconConvertor.String2Icon("Basket", true);
[attach]161[/attach]
//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();
}
}
作者:
ease
时间:
2014-2-9 13:12
翻土,标记学习
作者:
水木山人
时间:
2014-2-9 14:39
留下爪印,以后备用~
欢迎光临 FineUI 官方论坛 (https://fineui.com/BBS/)
Powered by Discuz! X3.4