Exemplo n.º 1
0
        /// <summary>
        /// Method creates correct collection of Fields for sort.
        /// </summary>
        /// <param name="currentFieldsForSort">Collection of Fields marked for sort.</param>
        /// <param name="incorrectFieldsForSort">Collection of incorrect Fields for sort.</param>
        /// <returns>Collection of sortable fields.</returns>
        private SortDescription[] _GetFieldsForSort(SortDescription[] currentFieldsForSort,
                                                    List <string> incorrectFieldsForSort)
        {
            // Calculate how many sort fields will stay in current Repository Settings.
            Int32 newPropertiesCount = currentFieldsForSort.Length - incorrectFieldsForSort.Count;

            SortDescription[] sortableFields = new SortDescription[newPropertiesCount];

            Int32 fieldsCounter = 0;

            // Copy all available fields from current Sort Descriptions to new ones.
            for (Int32 i = 0; i < currentFieldsForSort.Length; i++)
            {
                SortDescription descr = (SortDescription)currentFieldsForSort.GetValue(i);

                // Miss Fields which is not currently exists.
                if (!incorrectFieldsForSort.Contains(descr.PropertyName))
                {
                    sortableFields.SetValue(descr, fieldsCounter++);
                }
            }

            return(sortableFields);
        }