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);
     }
 }
Example #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)));
 }
Example #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)));
            }
        }
 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);
     }
 }
Example #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);
        }
Example #6
0
 public static IQueryable <TElement> ProcessBySpecification <TElement>(this IQueryable <TElement> source, PathDataSpecification spec)
 {
     return(source.ProcessBySpecification(spec, null));
 }