Пример #1
0
 public PathDataSpecification this[string path]
 {
     get
     {
         PathDataSpecification spec = this.PathDataSpecs.FirstOrDefault(pds => pds.PropertyPath == path);
         if (spec != null)
         {
             return(spec);
         }
         spec = new PathDataSpecification {
             PropertyPath = path
         };
         this.PathDataSpecs.Add(spec);
         return(spec);
     }
     set
     {
         PathDataSpecification spec = this.PathDataSpecs.FirstOrDefault(pds => pds.PropertyPath == path);
         if (spec != null)
         {
             this.PathDataSpecs.Remove(spec);
         }
         this.PathDataSpecs.Add(value);
     }
 }
Пример #2
0
 public PagingInfo(string dataPath, int pageNumbersWindow)
 {
     this.dataPath = dataPath;
     this.PageNumbersWindow = pageNumbersWindow;
     HttpContext httpc = HttpContext.Current;
     rds = RequestDataSpecification.Current;
     pathData = rds[dataPath];
     urlBase = httpc.Request.RawUrl.UpTo("?");
     queryValues = httpc.Request.RawUrl.After("?")
         .Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries)
         .Select(w => new KeyValuePair<string,string>(w.UpTo("="), w.After("=")))
         .ToList();
     foreach (var formField in httpc.Request.Form.ToKeyValues())
         queryValues.Add(new KeyValuePair<string,string>(formField.Key, HttpUtility.UrlEncode(formField.Value)));
 }
Пример #3
0
        public PagingInfo(string dataPath, int pageNumbersWindow)
        {
            this.dataPath          = dataPath;
            this.PageNumbersWindow = pageNumbersWindow;
            HttpContext httpc = HttpContext.Current;

            rds         = RequestDataSpecification.Current;
            pathData    = rds[dataPath];
            urlBase     = httpc.Request.RawUrl.UpTo("?");
            queryValues = httpc.Request.RawUrl.After("?")
                          .Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries)
                          .Select(w => new KeyValuePair <string, string>(w.UpTo("="), w.After("=")))
                          .ToList();
            foreach (var formField in httpc.Request.Form.ToKeyValues())
            {
                queryValues.Add(new KeyValuePair <string, string>(formField.Key, HttpUtility.UrlEncode(formField.Value)));
            }
        }
Пример #4
0
 public PathDataSpecification this[string path]
 {
     get
     {
         PathDataSpecification spec = this.PathDataSpecs.FirstOrDefault(pds => pds.PropertyPath == path);
         if (spec != null) return spec;
         spec = new PathDataSpecification { PropertyPath = path };
         this.PathDataSpecs.Add(spec);
         return spec;
     }
     set
     {
         PathDataSpecification spec = this.PathDataSpecs.FirstOrDefault(pds => pds.PropertyPath == path);
         if (spec != null)
             this.PathDataSpecs.Remove(spec);
         this.PathDataSpecs.Add(value);
     }
 }
Пример #5
0
        public static IQueryable <TElement> ProcessBySpecification <TElement>(this IQueryable <TElement> source, PathDataSpecification spec, int?pageLength)
        {
            IQueryable <TElement> result = source;

            if (!string.IsNullOrEmpty(spec.FilterExpression))
            {
                result = result.Where(spec.FilterExpression);
            }
            bool doPaging = (pageLength.HasValue || (spec.Page.HasValue && spec.PageLength.HasValue));

            if (doPaging)
            {
                spec.FilteredCount = result.Count();
            }
            if (!string.IsNullOrEmpty(spec.SortKey))
            {
                result = result.OrderBy(spec.SortKey);
            }
            if (doPaging)
            {
                spec.Page       = spec.Page ?? 0;
                spec.PageLength = pageLength ?? spec.PageLength.Value;
                result          = result.Skip(spec.PageLength.Value * spec.Page.Value).Take(spec.PageLength.Value);
            }

            return(result);
        }
Пример #6
0
 public static IQueryable <TElement> ProcessBySpecification <TElement>(this IQueryable <TElement> source, PathDataSpecification spec)
 {
     return(source.ProcessBySpecification(spec, null));
 }