[IronPython] InvokeMember with three or more parameters.

Dino Viehland dinov at microsoft.com
Wed Aug 19 09:28:51 CEST 2009


This should do it:

scriptScope.GetVariable<Func<object>>("Broker")();

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Pavel Suhotyuk
Sent: Wednesday, August 19, 2009 12:20 AM
To: Discussion of IronPython
Subject: Re: [IronPython] InvokeMember with three or more parameters.

Hello.

Thank you for answer.

How can I create script object without code generation same like:

scriptEngine.Execute(string.Format("{0}()","Broker"),scriptScope);

?

Dino Viehland wrote:
> We haven't implemented support for more than 3 parameters :)
>
> In 2.6 I just fixed > 3 params for the Invoke case (not InvokeMember)
> and I can fix > 3 for InvokeMember/CreateInstance as well before
> 2.6 ships.
>
> The preferred way to do this though is to do a GetMember<T> where
> T is a delegate type with > 3 paraemters.  Then you can just invoke
> the delegate.
>
>> -----Original Message-----
>> From: users-bounces at lists.ironpython.com [mailto:users-
>> bounces at lists.ironpython.com] On Behalf Of Pavel Suhotyuk
>> Sent: Monday, August 17, 2009 1:19 AM
>> To: Discussion of IronPython
>> Subject: [IronPython] InvokeMember with three or more parameters.
>>
>> Hello.
>>
>> I have Python code:
>>
>> class Broker ( object ) :
>>
>>      def validation( self, info, provider_manager ):
>>          pass
>>
>>      def check( self, payment, payment_manager, provider_manager ):
>>          pass
>>
>> and try to call methods by this c# code:
>>
>> operations = scriptEngine.CreateOperations();
>> var scriptSource =
>> scriptEngine.CreateScriptSourceFromString(script,SourceCodeKind.Stateme
>> nts);
>> scriptCode = scriptSource.Compile();
>> scriptCode.Execute();
>> scriptScope = scriptCode.DefaultScope;
>> broker =
>> scriptEngine.Execute(string.Format("{0}()","Broker"),scriptScope);
>>
>> bool validationResult = operations.InvokeMember(broker, "validation",
>> paymentInfo, providerManager);
>>
>> operations.InvokeMember(broker, "check", payment, paymentManager,
>> providerManager);
>>
>>
>> Invoke validation method is success, but invoke check method throws
>> NotImplementedException with stack trace:
>>
>> System.NotImplementedException: Method or operation not implemented.
>>     в Microsoft.Scripting.Runtime.DynamicOperations.InvokeMember(Object
>> obj, String memberName, Boolean ignoreCase, Object[] parameters)
>>     в Microsoft.Scripting.Hosting.ObjectOperations.InvokeMember(Object
>> obj, String memberName, Object[] parameters)
>>
>> Looks like 2 paramters called correct, but more than 2 throws exception
>> in all cases.
>>
>> Why it happens?
>>
>> --
>> Best regards,
>>   Suhotjuk Pavel Sergeevich
>> _______________________________________________
>> Users mailing list
>> Users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


More information about the Ironpython-users mailing list