public static ObjectCompilerSetting BuildUpDefaultObjectCompilerSetting <T>(this SearchQueryCompilerBuilder instance) { var setting = new ObjectCompilerSetting(); RegisterDynamicVariableEvaluatorForYearTimeSpan(setting.DynamicVariableEvaluator); RegisterDynamicVariableEvaluatorForMonthTimeSpan(setting.DynamicVariableEvaluator); RegisterDynamicVariableEvaluatorForDayTimeSpan(setting.DynamicVariableEvaluator); setting.StaticVariableEvaluator.RegisterVariable("Now", () => DateTime.Now, "Now"); setting.StaticVariableEvaluator.RegisterVariable("Today", () => DateTime.Today, "Today"); setting.Evaluators.Add(new PropertyEvaluator <T>()); setting.Evaluators.Add(setting.DynamicVariableEvaluator); setting.Evaluators.Add(setting.StaticVariableEvaluator); setting.Evaluators.Add(new TypeConversionEvaluator()); setting.Operators.Add(new NotPartialMatch <T>("!:", true, OperatorIndependency.Strong, "Not Partial matching operator")); setting.Operators.Add(new PartialMatch <T>(":", true, OperatorIndependency.Strong, "Partial matching operator")); setting.Operators.Add(new PrefixSearch <T>("=:", true, OperatorIndependency.Strong, "Prefix search operator")); setting.Operators.Add(new SuffixSearch <T>(":=", true, OperatorIndependency.Strong, "Suffix search operator")); setting.Operators.Add(new Equal <T>("=", true, OperatorIndependency.Strong, "Equal operator")); setting.Operators.Add(new NotEqual <T>("!=", true, OperatorIndependency.Strong, "Not equal operator")); setting.Operators.Add(new LessThan <T>("<", OperatorIndependency.Strong, "Less than operator")); setting.Operators.Add(new LessThanOrEqual <T>("<=", OperatorIndependency.Strong, "Less than or equal operator")); setting.Operators.Add(new GreaterThan <T>(">", OperatorIndependency.Strong, "Greater than operator")); setting.Operators.Add(new GreaterThanOrEqual <T>(">=", OperatorIndependency.Strong, "Greater than or equal operator")); setting.Operators.Add(new Add("+", 1, OperatorIndependency.Strong, "Add operator")); setting.Operators.Add(new Subtract("-", 1, OperatorIndependency.Strong, "Subtract operator")); setting.Operators.Add(new Multiply("*", 0, OperatorIndependency.Strong, "Multiply operator")); setting.Operators.Add(new Divide("/", 0, OperatorIndependency.Strong, "Divide operator")); return(setting); }
/// <summary> /// Builds up a search query compiler with default setting that is optimized for LINQ to Object. /// </summary> /// <typeparam name="T">The type of an elements in a collection that is filtered by a generated expression.</typeparam> /// <param name="instance">The search query compiler builder.</param> /// <returns>The default search query compiler that is optimized for LINQ to Object.</returns> public static SearchQueryCompiler <T> BuildUpDefaultCompilerForObject <T>(this SearchQueryCompilerBuilder instance) { var setting = instance.BuildUpDefaultObjectCompilerSetting <T>(); return(instance.BuildUpCompiler <T>(setting)); }