Example #1
0
		/////////////////////////////////////////////////////////////////////////////

		//public override object EvalMethodCallExpression( object objIn, MethodCallExpression exp )
		//{
		//	// ******
		//	//
		//	// expression:  macro.method(..)
		//	//
		//	// exp.MemberName should be a method on the object passed in to us, it is the
		//	// method that we need to retreive and then invoke
		//	//
		//	object objResult = null;
		//	object [] args = EvaluateArguments( exp.Arguments );
		//	
		//	// ******
		//	Invoker invoker = Invokers.GetMethodInvoker( objIn, exp.MethodName );
		//	if( null != invoker ) {
		//		objResult = invoker.Invoke( args );
		//	}
		//	else {
		//		//
		//		// could be a "raw" delegate
		//		//
		//		var oInfo = new ObjectInfo( objIn, exp.MethodName );
		//		if( oInfo.IsDelegate ) {
		//			objResult = oInfo.GetDelegateValue( args );
		//		}
		//		else {
		//			ThreadContext.MacroError( "there is no method or delegate named \"{0}\" on the object type \"{1}\"", exp.MethodName, ObjectInfo.GetTypeName(objIn) );
		//		}
		//	}
		//
		//	// ******
		//	CheckNullResult( objResult, objIn, exp.MethodName );
		//	return objResult;
		//}


		public override object EvalMethodCallExpression( object objIn, MethodCallExpression exp )
		{
			// ******
			//
			// expression:  macro.method(..)
			//
			// exp.MemberName should be a method on the object passed in to us, it is the
			// method that we need to retreive and then invoke
			//
			object objResult = null;
			object [] args = EvaluateArguments( exp.Arguments );
			
			// ******
			//Invoker invoker = Invokers.GetMethodInvoker( objIn, exp.MethodName );
			Invoker invoker = Invokers.GetMethodInvoker( objIn, exp.MethodName, typeHelpers );
			if( null != invoker ) {
				objResult = invoker.Invoke( args );
			}
			else {
				//
				// could be a "raw" delegate
				//
				var oInfo = new ObjectInfo( objIn, exp.MethodName );
				if( oInfo.IsDelegate ) {
					objResult = oInfo.GetDelegateValue( args );
				}
				else {
					ThreadContext.MacroError( "there is no method or delegate named \"{0}\" on the object type \"{1}\"", exp.MethodName, ObjectInfo.GetTypeName(objIn) );
				}
			}

			// ******
			CheckNullResult( objResult, objIn, exp.MethodName );
			return objResult;
		}