Ejemplo n.º 1
0
 public BindingListSortService(List <T> unsortedList, DataGridView grid, SortConfiguration sortConfiguration, ISortService <T> sortService)
 {
     _unsortedList      = unsortedList;
     _grid              = grid;
     _sortConfiguration = sortConfiguration;
     _sortService       = sortService;
 }
Ejemplo n.º 2
0
 public GridMetamodelBuilder <TGridModel> AddDefaultSortColumn <TColumn>(
     Expression <Func <TGridModel, TColumn> > property, SortMode sortMode, int width = 150,
     ColumnWidthMode widthMode     = ColumnWidthMode.Auto,
     FilterOperator filterOperator = FilterOperator.Auto)
 {
     this.defaultSortSettings = new SortConfiguration(ObjectHelper.GetPropertyName(property), sortMode);
     return(this.AddDataColumn(property, width, widthMode, filterOperator));
 }
Ejemplo n.º 3
0
        private DataPageResult <OrderGridModel> GetDataPage(SortConfiguration sortConfiguration)
        {
            var filterConfiguration = GridConfigurationHelper.GetFilter(this.FilterProperty, this.FilterValue);

            var request  = new DataRequest <OrderGridModel>(this.pageNumber, this.pageSize, sortConfiguration, filterConfiguration);
            var dataPage = this.GetService().GetDataPage(request);

            return(dataPage);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Return a list of string representing media files in the local sort directory
        /// </summary>
        public static List <string> GetLocalSortDirectoryContents(this SortConfiguration _SortConfig)
        {
            List <string> _finalSortFiles = new List <string>();

            foreach (string _file in Directory.GetFiles(_SortConfig.LocalSortDirectory))
            {
                _finalSortFiles.Add(_file);
            }

            return(_finalSortFiles);
        }
Ejemplo n.º 5
0
        private static SortConfiguration PrepareSortSettings(
            GridSettings gridSettings, SortConfiguration defaultSortSettings)
        {
            if (string.IsNullOrEmpty(gridSettings.SortColumn))
            {
                return(defaultSortSettings);
            }

            var sortMode = gridSettings.SortOrder == "asc" ? SortMode.Ascending : SortMode.Descending;

            return(new SortConfiguration(gridSettings.SortColumn, sortMode));
        }
Ejemplo n.º 6
0
        public static QueryOver <TPersistenceModel, TPersistenceModel> ApplyOrder <TPersistenceModel>(
            this QueryOver <TPersistenceModel, TPersistenceModel> query,
            SortConfiguration sortSettings, ViewModelToPersistenceModelPropertyNamesMaps viewModelToPersistenceModelMap)
            where TPersistenceModel : IPersistenceModel
        {
            if (!viewModelToPersistenceModelMap.AllProperties.ContainsKey(sortSettings.PropertyName))
            {
                throw new ApplicationException("Property used to sort can not be found in ViewModelToPersistenceModelMap. Grid metamodel is probably broken.");
            }

            bool   ascending        = sortSettings.Mode == SortMode.Ascending;
            string sortPropertyName = viewModelToPersistenceModelMap.AllProperties[sortSettings.PropertyName];

            query.UnderlyingCriteria.AddOrder(new Order(sortPropertyName, ascending));

            return(query);
        }
Ejemplo n.º 7
0
        public DataRequest(int currentPageNumber, int pageSize,
                           SortConfiguration sortConfiguration, FilterConfiguration <TGridModel> filterConfiguration)
        {
            if (sortConfiguration == null)
            {
                throw new ArgumentException("sortConfiguration");
            }
            if (filterConfiguration == null)
            {
                throw new ArgumentNullException("filterConfiguration");
            }

            this.PageNumber          = currentPageNumber;
            this.PageSize            = pageSize;
            this.FilterConfiguration = filterConfiguration;
            this.SortConfiguration   = sortConfiguration;
        }
Ejemplo n.º 8
0
        public void sortservice_will_update_sort_configuration_lastsortbycolumn_test()
        {
            //given a list
            List <BluRaySummaryInfo> unsortedList = new List <BluRaySummaryInfo>()
            {
                new BluRaySummaryInfo()
                {
                    Eac3ToId = "8)", BluRayTitleInfo = new BluRayTitleInfo()
                    {
                        EpisodeNumber = "8"
                    }
                }, new BluRaySummaryInfo()
                {
                    Eac3ToId = "1)", BluRayTitleInfo = new BluRayTitleInfo()
                    {
                        EpisodeNumber = "1"
                    }
                },
                new BluRaySummaryInfo()
                {
                    Eac3ToId = "4)", BluRayTitleInfo = new BluRayTitleInfo()
                    {
                        EpisodeNumber = "4"
                    }
                }
            };
            //when i attempt to sort by a column in desc order
            SortConfiguration config = new SortConfiguration()
            {
                LastSortByColumnName = string.Empty, SortByColumnName = "EpisodeNumber", SortDirection = EnumSortDirection.Asc
            };
            ISortService <BluRaySummaryInfo> service = new SortService <BluRaySummaryInfo>(config, unsortedList);
            //list should be ordered by column in desc order
            List <BluRaySummaryInfo> sortedList = service.Sort();

            config.LastSortByColumnName.Should().Be("EpisodeNumber");
        }
Ejemplo n.º 9
0
 public SortService(SortConfiguration sortConfiguration, List <T> unSortedList)
 {
     _sortConfiguration = sortConfiguration;
     _unSortedList      = unSortedList;
 }