public static Expression <T> Parse <T>(string source) { var parseResult = SymbolParser.Build(source); var parser = new ExpressionParserCore(parseResult, typeof(T), null, null); return(parser.ToLambdaExpression <T>()); }
/// <summary> /// 将源字符串分析为委托. /// </summary> /// <typeparam name="T">委托类型</typeparam> /// <param name="source">用于分析的源字符串.</param> /// <param name="assemblies">可能用到的程序集列表.</param> /// <param name="ns">分析过程中可能用到的命名空间列表.</param> /// <returns> /// 分析委托. /// </returns> public static T Compile <T>(string source, Assembly[] assemblies, params string[] ns) { var parseResult = SymbolParser.Build(source); var parser = new ExpressionParserCore(parseResult, typeof(T), ns, assemblies); return(parser.ToLambdaExpression <T>().Compile()); }
/// <summary> /// 将源字符串分析为委托. /// </summary> /// <typeparam name="T">委托类型</typeparam> /// <param name="source">用于分析的源字符串.</param> /// <param name="ns">分析过程中可能用到的命名空间列表.</param> /// <returns>分析委托.</returns> public static Func <T, bool> Compile <T>(string source, params string[] ns) { var parseResult = SymbolParser.Build(source); var parser = new ExpressionParserCore <T>(parseResult, typeof(T), ns, null); return(parser.ToLambdaExpression <T>().Compile()); }