using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace AzyleeCC.Core.DataUtils.EnumUtils { /// /// 标志枚举修改工具 /// 弃用:效率太低 /// sa = sa | StatusAttributes.Join;//添加属性 /// sa = (sa | StatusAttributes.Share) ^ StatusAttributes.Share;//删除属性 /// [Obsolete] public sealed class FlagsEnumTool { public static int AddAttribute(int en, int att) { return en ^ att; } public static int AddAttribute(T en, T att) { try { int intEn = (int)Convert.ChangeType(en, typeof(int)); int intAtt = (int)Convert.ChangeType(att, typeof(int)); return intEn ^ intAtt; } catch (Exception e) { } return 0; } public static int RemoveAttribute(int en, int att) { return (en | att) ^ att; } public static int RemoveAttribute(T en, T att) { try { int intEn = (int)Convert.ChangeType(en, typeof(int)); int intAtt = (int)Convert.ChangeType(att, typeof(int)); return (intEn | intAtt) ^ intAtt; } catch (Exception e) { } return 0; } } }