コード例 #1
0
 public static string EvaluateToString( string strCSharpCode )
 {
     Evaluator eval	= new Evaluator( typeof( string ),
         strCSharpCode,
         strStaticMethodName );
     return ( string ) eval.Evaluate( strStaticMethodName );
 }
コード例 #2
0
 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 );
 }
コード例 #3
0
 public static Decimal EvaluateToDecimal( string strCSharpCode )
 {
     Evaluator eval	= new Evaluator( typeof( Decimal ),
         strCSharpCode,
         strStaticMethodName );
     return ( Decimal ) eval.Evaluate( strStaticMethodName );
 }
コード例 #4
0
 // 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 );
 }
コード例 #5
0
 public static bool EvaluateToBool( string strCSharpCode )
 {
     Evaluator eval	= new Evaluator( typeof( bool ),
         strCSharpCode,
         strStaticMethodName );
     return ( bool ) eval.Evaluate( strStaticMethodName );
 }