예제 #1
0
        /// <summary>
        /// 把查询操作的枚举表示转换为操作码
        /// </summary>
        /// <param name="operate">查询操作的枚举表示</param>
        public static string ToOperateCode(this FilterOperate operate)
        {
            Type type = operate.GetType();

            MemberInfo[] members = type.GetMember(operate.CastTo <string>());
            if (members.Length > 0)
            {
                OperateCodeAttribute attribute = members[0].GetAttribute <OperateCodeAttribute>();
                return(attribute == null ? null : attribute.Code);
            }
            return(null);
        }
        /// <summary>
        /// 把查询操作的枚举表示转换为操作码
        /// </summary>
        /// <param name="operate">查询操作的枚举表示</param>
        public static string ToOperateCode(this FilterOperate operate)
        {
            Type type = operate.GetType();

            MemberInfo[] members = type.GetMember(operate.CastTo <string>());
            if (members.Length > 0)
            {
                object[] attributes = members[0].GetCustomAttributes(typeof(OperateCodeAttribute), false);
                if (attributes.Length > 0)
                {
                    return(((OperateCodeAttribute)attributes[0]).Code);
                }
            }
            return(null);
        }
예제 #3
0
        /// <summary>
        ///     把查询操作的枚举表示转换为操作名称
        /// </summary>
        /// <param name="operate">查询操作的枚举表示</param>
        /// <returns></returns>
        public static string ToOperateName(this FilterOperate operate)
        {
            var type    = operate.GetType();
            var members = type.GetMember(operate.CastTo <string>());

            if (members.Length > 0)
            {
                var attributes = members[0].GetCustomAttributes(typeof(OperateCodeAttribute), false);
                if (attributes.Length > 0)
                {
                    return(((OperateCodeAttribute)attributes[0]).Name);
                }
            }
            return(null);
        }