Beispiel #1
0
        public static int DefaultSortComparison(object x, object y)
        {
            if (x == null)
            {
                if (y == null)
                {
                    return(0);
                }
                else
                {
                    return(-1);
                }
            }
            else
            {
                if (y == null)
                {
                    return(1);
                }
                else
                {
                    Type xType = x.GetType();
                    Type yType = y.GetType();

                    ViewSortHintAttribute xAttribute = xType.GetCustomAttributes(typeof(ViewSortHintAttribute), true).FirstOrDefault() as ViewSortHintAttribute;
                    ViewSortHintAttribute yAttribute = yType.GetCustomAttributes(typeof(ViewSortHintAttribute), true).FirstOrDefault() as ViewSortHintAttribute;

                    return(ViewSortHintAttributeComparison(xAttribute, yAttribute));
                }
            }
        }
Beispiel #2
0
 private static int ViewSortHintAttributeComparison(ViewSortHintAttribute x, ViewSortHintAttribute y)
 {
     if (x == null)
     {
         if (y == null)
         {
             return(0);
         }
         else
         {
             return(-1);
         }
     }
     else
     {
         if (y == null)
         {
             return(1);
         }
         else
         {
             return(string.Compare(x.Hint, y.Hint, StringComparison.Ordinal));
         }
     }
 }
Beispiel #3
0
 private static int ViewSortHintAttributeComparison(ViewSortHintAttribute x, ViewSortHintAttribute y)
 {
     if (x == null)
     {
         if (y == null)
         {
             return 0;
         }
         else
         {
             return -1;
         }
     }
     else
     {
         if (y == null)
         {
             return 1;
         }
         else
         {
             return string.Compare(x.Hint, y.Hint, StringComparison.Ordinal);
         }
     }
 }