public static string EvaluateToString( string strCSharpCode ) { Evaluator eval = new Evaluator( typeof( string ), strCSharpCode, strStaticMethodName ); return ( string ) eval.Evaluate( strStaticMethodName ); }
public static object EvaluateToObject( string strCSharpCode ) { // this will compile the code passed as argument inside a function // named __foo and then execute the function and return the result Evaluator eval = new Evaluator( typeof( object ), strCSharpCode, strStaticMethodName ); return eval.Evaluate( strStaticMethodName ); }
public static Decimal EvaluateToDecimal( string strCSharpCode ) { Evaluator eval = new Evaluator( typeof( Decimal ), strCSharpCode, strStaticMethodName ); return ( Decimal ) eval.Evaluate( strStaticMethodName ); }
// static methods that evaluate the C# code passed // if needed, additional typed Evaluate methods can be created public static int EvaluateToInteger( string strCSharpCode ) { Evaluator eval = new Evaluator( typeof( int ), strCSharpCode, strStaticMethodName ); return ( int ) eval.Evaluate( strStaticMethodName ); }
public static bool EvaluateToBool( string strCSharpCode ) { Evaluator eval = new Evaluator( typeof( bool ), strCSharpCode, strStaticMethodName ); return ( bool ) eval.Evaluate( strStaticMethodName ); }