public Func <T, bool> GetFunctionForExpressFormsFilters <T>(Dictionary <string, ExpressFormsFilter> filters, Dictionary <string, Dictionary <string, string> > filterEntries) { DynamicMethod method = new DynamicMethod("Filter", typeof(bool), new Type[] { typeof(T) }); ILGenerator generator = method.GetILGenerator(); PropertyInfo[] propertiesToFilterOn = typeof(T).GetProperties() .Where(p => PropertyNames.Contains(p.Name)) .ToArray(); int variableIndex = 0; foreach (PropertyInfo property in propertiesToFilterOn) { // Generate IL variable declarations. // First, check that a filter has been provided for this property to avoid errors. if (!filters.Keys.Contains(property.Name)) { continue; } ExpressFormsFilter filter = filters[property.Name]; filter.GenerateFilterLocalDeclarations(generator, variableIndex, out variableIndex); } foreach (PropertyInfo property in propertiesToFilterOn) { // Generate IL to implement filtering // First, check that a filter has been provided for this property to avoid errors. if (!filters.Keys.Contains(property.Name) || !filterEntries.Keys.Contains(property.Name)) { continue; } ExpressFormsFilter filter = filters[property.Name]; Dictionary <string, string> filterEntry = filterEntries[property.Name]; filter.GenerateFilterIl(generator, filterEntry, property); } generator.EmitReturnTrue(); return((Func <T, bool>)(method.CreateDelegate(typeof(Func <T, bool>)))); }
public ExpressFormsPassThruFilter(ExpressFormsFilter filter) : base(filter) { PartialViewName = "ExpressFormsFilters/NoFilterAvailable"; }
public ExpressFormsFilterNumber(ExpressFormsFilter filter) : base(filter) { PartialViewName = "ExpressFormsFilters/ExpressFormsFilterNumber"; }
public ExpressFormsFilterText(ExpressFormsFilter filter) : base(filter) { PartialViewName = "ExpressFormsFilters/ExpressFormsFilterText"; }
public ExpressFormsFilterDate(ExpressFormsFilter filter) : base(filter) { PartialViewName = "ExpressFormsFilters/ExpressFormsFilterDate"; }
public ExpressFormsFilterBool(ExpressFormsFilter filter) : base(filter) { PartialViewName = "ExpressFormsFilters/ExpressFormsFilterBool"; }