I think you want to do:
rancore.Repository.ElementRepository.CreateAdapterForPath[str][str](...)
or:
rancore.Repository.ElementRepository.CreateAdapterForPath[str].Overloads[str][str](...)
or:
rancore.Repository.ElementRepository.CreateAdapterForPath[str][str].Overloads[str](...)
I think the 2nd two will be equivalent but just perform the operations in a
different order. The 1st should give you a generic method which has both
overloads.
Overloads is for selecting one of the various methods. So you have 3 things to
index into:
The generic type, to provide it's type parameters
The generic method, to provide the method's type parameters
The Overloads, to select an individual method out of the set of
overloaded methods.
There still might be a generic constraint that you're violating though.
Looking at the API my guess would be that there is a constraint that the object
must implement new. You might try:
rancore.Repository.ElementRepository.CreateAdapterForPath[str][object](...)
as object contains a default constructor. If that doesn't work then you'll
need to get the constraints which should be in the docs or you could open the
assembly with reflector.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Jason Galyon
Sent: Tuesday, November 11, 2008 5:43 PM
To: [email protected]
Subject: [IronPython] IronPython 1.1.2 and overloaded or generic methods
Howdy,
I am new to IronPython with absolutely no knowledge yet of .NET/CLR.
I am trying to use IronPython with a new API from a particular system
where the methods are overloaded as you can see below from the
interactive prompt.
How do I call a particular method with the signature I want?
Secondary question is whether there will ever be a more Pythonic way of
dealing with these?
Thanks in advance for any information!
Jason
IronPython 1.1.2 (1.1.2) on .NET 2.0.50727.3053
Copyright (c) Microsoft Corporation. All rights reserved.
... add reference and importing ...
>>> rancore.Repository.ElementRepository.CreateAdapterForPath.Overloads
<IronPython.Runtime.Calls.BuiltinFunctionOverloadMapper object at
0x000000000000
0030 [{'T CreateAdapterForPath[T](str path)': <built-in function
CreateAdapterFo
rPath>, 'T CreateAdapterForPath[T](str path, int timeout)': <built-in
function C
reateAdapterForPath>}]>
>>>
rancore.Repository.ElementRepository.CreateAdapterForPath[str].Overloads[str
]('/[EMAIL PROTECTED]"System\ Requirements\ -\ Mozilla')
Traceback (most recent call last):
File , line 0, in <stdin>##79
ValueError: GenericArguments[0], 'System.String', on 'T
CreateAdapterForPath[T](
System.String)' violates the constraint of type 'T'.
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com