Exemplo n.º 1
0
        /// <summary>
        /// 创建 URL 的实现代码
        /// </summary>
        /// <param name="urlBuilder"></param>
        /// <param name="filters">IEnumerable&lt;IFilterPart&gt;</param>
        /// <param name="sorts">IEnumerable&lt;ISortPart&gt;</param>
        /// <param name="pageIndex"></param>
        /// <returns></returns>
        private string BuildUrl(IUrlBuilder urlBuilder, IEnumerable<IFilterPart> filters, IEnumerable<ISortPart> sorts, int pageIndex)
        {
            urlBuilder.Initialize(this.ContentType);

            urlBuilder.BeginFilter();
            foreach (IFilterPart part in filters)
            {
                part.BuildUrl(urlBuilder);
            }
            urlBuilder.EndFilter();

            urlBuilder.BeginSort();
            foreach (ISortPart part in sorts)
            {
                part.BuildUrl(urlBuilder);
            }
            urlBuilder.EndSort();

            urlBuilder.SetPageSize(this.PageSize);

            return urlBuilder.GetUrl(pageIndex);
        }