コード例 #1
0
        public static Tuple <PropertyInfo, string> GetSortField <T>(this object obj, IDTO_Sort sortField)
        {
            Type type = typeof(T);

            PropertyInfo[] piArray = type.GetProperties();

            return(piArray.GetSortField <T>(sortField));
        }
コード例 #2
0
        public static Tuple <PropertyInfo, string> GetSortField <T>(this PropertyInfo[] piArray, IDTO_Sort sortField)
        {
            foreach (var pi in piArray)
            {
                var attr = pi.GetCustomAttribute <SortFieldAttribute>();
                if (attr != null && attr.NickNames.Contains(sortField.FieldName, StringComparer.OrdinalIgnoreCase))
                {
                    return(new Tuple <PropertyInfo, string>(pi, attr.RealName));
                }

                if (pi.Name.Equals(sortField.FieldName, StringComparison.OrdinalIgnoreCase))
                {
                    return(new Tuple <PropertyInfo, string>(pi, pi.Name));
                }
            }

            return(null);
        }