/// <summary> /// /// </summary> /// <typeparam name="TModel"></typeparam> /// <param name="column"></param> /// <param name="search"></param> /// <param name="parameterExpression"></param> /// <returns></returns> /// <exception cref="NotSupportedException">Thrown when the searchquery is based on an regular expression</exception> public override Expression <Func <TModel, bool> > GetExpression <TModel>(IColumn column, ISearch search, ParameterExpression parameterExpression) { var sourcePropertyName = column.Field ?? column.Name; var sourceProperty = GetProperty <TModel> .ByName(sourcePropertyName); var logicalMethod = TargetType.GetMethod(nameof(string.Contains), new[] { typeof(string), typeof(StringComparison) }); var expression = Expression.Call(Expression.Property(parameterExpression, sourceProperty), logicalMethod, Expression.Constant(search.Value), Expression.Constant(StringComparison.CurrentCultureIgnoreCase)); return(Expression.Lambda <Func <TModel, bool> >(expression, new ParameterExpression[] { parameterExpression })); }
public object GetObject() { Type[] argTypes = ResolveMethodArgTypes(); object[] argValues = PrepareMethodArgs(TargetMethodArgs, argTypes); MethodInfo mInfo = TargetType.GetMethod(TargetMethod, BindingFlags.Static | BindingFlags.Public, null, argTypes, null); if (mInfo == null) { throw new MissingMethodException(TargetType.ToString(), TargetMethod); } return(mInfo.Invoke(null, BindingFlags.Static | BindingFlags.Public, null, argValues, null)); }
private void FindAndSetTarget(Type targetType, string methodOrField = null) { TargetType = TargetAssembly.MainModule.GetType(targetType.FullName); if (string.IsNullOrWhiteSpace(methodOrField)) { return; } TargetMethod = TargetType.GetMethod(methodOrField); if (TargetMethod != null) { return; } TargetField = TargetType.GetField(methodOrField); }
public Type GetObjectType() { MethodInfo mInfo = TargetType.GetMethod(TargetMethod, BindingFlags.Static | BindingFlags.Public, null, ResolveMethodArgTypes(), null); return(mInfo.ReturnType); }