public static FilterOperate GetFilterOperate(string code) { Type type = typeof(FilterOperate); MemberInfo[] members = type.GetMembers(BindingFlags.Public | BindingFlags.Static); foreach (var member in members) { FilterOperate operate = member.Name.CastTo <FilterOperate>(); if (operate.ToOperateCode() == code) { return(operate); } } throw new NotSupportedException("获取操作码的查询操作枚举表示时不支持代码:" + code); }
/// <summary> /// 获取操作码的查询操作枚举表示 /// </summary> /// <param name="code">操作码</param> /// <returns></returns> public static FilterOperate GetFilterOperate(string code) { if (string.IsNullOrEmpty(code)) { throw new ArgumentNullException("message"); } Type type = typeof(FilterOperate); MemberInfo[] members = type.GetMembers(BindingFlags.Public | BindingFlags.Static); foreach (MemberInfo member in members) { FilterOperate operate = member.Name.CastTo <FilterOperate>(); if (operate.ToOperateCode() == code) { return(operate); } } throw new NotSupportedException("获取操作码的查询操作枚举表示时不支持代码:" + code); }