示例#1
0
        // Private Methods
        private SortPropertyInfo[] CreatePropertyInfo(SortDescriptionCollection sortFields)
        {
            SortPropertyInfo[] fields = new SortPropertyInfo[sortFields.Count];
            for (int k = 0; k < sortFields.Count; ++k)
            {
                PropertyPath pp;
                if (String.IsNullOrEmpty(sortFields[k].PropertyName))
                {
                    // sort by the object itself (as opposed to a property)
                    pp = null;
                }
                else
                {
                    // sort by the value of a property path, to be applied to
                    // the items in the list
                    pp = new PropertyPath(sortFields[k].PropertyName);
                }

                // remember PropertyPath and direction, used when actually sorting
                fields[k].index      = k;
                fields[k].info       = pp;
                fields[k].descending = (sortFields[k].Direction == ListSortDirection.Descending);
            }
            return(fields);
        }
示例#2
0
        private static SortPropertyInfo[] CreatePropertyInfo(SortDescriptionCollection sortFields)
        {
            SortPropertyInfo[] fields = new SortPropertyInfo[sortFields.Count];
            for (int k = 0; k < sortFields.Count; ++k)
            {
                IComparer propertyComparer;
                if (String.IsNullOrEmpty(sortFields[k].PropertyName))
                {
                    // sort by the object itself (as opposed to a property) with a default comparer
                    propertyComparer = Comparer <T> .Default;
                }
                else
                {
                    // sort by the value of a property path, to be applied to
                    // the items in the list
                    Type propertyType = typeof(T).GetNestedPropertyType(sortFields[k].PropertyName);
                    if (propertyType == null)
                    {
                        throw CollectionViewError.ListCollectionView.InvalidPropertyName(sortFields[k].PropertyName);
                    }

                    //dynamically create comparer for property type
                    Type comparerType = typeof(Comparer <>).MakeGenericType(new Type[] { propertyType });
                    propertyComparer = (IComparer)comparerType.GetProperty("Default").GetValue(null, null);
                }

                // remember PropertyPath and direction, used when actually sorting
                fields[k].propertyPath = sortFields[k].PropertyName;
                fields[k].descending   = (sortFields[k].Direction == ListSortDirection.Descending);
                fields[k].comparer     = propertyComparer;
            }
            return(fields);
        }
示例#3
0
        private SortPropertyInfo[] CreatePropertyInfo(SortDescriptionCollection sortDescriptions)
        {
            var properties = new SortPropertyInfo[sortDescriptions.Count];

            for (int i = 0; i < sortDescriptions.Count; i++)
            {
                properties[i].PropertyName = sortDescriptions[i].PropertyName;
                properties[i].Descending   = sortDescriptions[i].Direction == ListSortDirection.Descending;
            }
            return(properties);
        }
示例#4
0
        // Private Methods 
        private SortPropertyInfo[] CreatePropertyInfo(SortDescriptionCollection sortFields)
        {
            SortPropertyInfo[] fields = new SortPropertyInfo[sortFields.Count];
            for (int k = 0; k < sortFields.Count; ++k) 
            {
                PropertyPath pp; 
                if (String.IsNullOrEmpty(sortFields[k].PropertyName)) 
                {
                    // sort by the object itself (as opposed to a property) 
                    pp = null;
                }
                else
                { 
                    // sort by the value of a property path, to be applied to
                    // the items in the list 
                    pp = new PropertyPath(sortFields[k].PropertyName); 
                }
 
                // remember PropertyPath and direction, used when actually sorting
                fields[k].index = k;
                fields[k].info = pp;
                fields[k].descending = (sortFields[k].Direction == ListSortDirection.Descending); 
            }
            return fields; 
        } 
 private static SortPropertyInfo[] CreatePropertyInfo(SortDescriptionCollection sortFields)
 {
     SortPropertyInfo[] fields = new SortPropertyInfo[sortFields.Count];
     for (int k = 0; k < sortFields.Count; ++k)
     {
         // remember PropertyPath and Direction, used when actually sorting
         fields[k].PropertyPath = sortFields[k].PropertyName;
         fields[k].Descending = (sortFields[k].Direction == ListSortDirection.Descending);
     }
     return fields;
 }
示例#6
0
 private static SortPropertyInfo[] CreatePropertyInfo(SortDescriptionCollection sortFields)
 {
     SortPropertyInfo[] infoArray = new SortPropertyInfo[sortFields.Count];
     for (int i = 0; i < sortFields.Count; i++)
     {
         SortDescription description = sortFields[i];
         infoArray[i].PropertyPath = description.PropertyName;
         SortDescription description2 = sortFields[i];
         infoArray[i].Descending = description2.Direction == ListSortDirection.Descending;
     }
     return infoArray;
 }