Hey,
On Wed, Mar 24, 2010 at 6:10 PM, Timwi <[email protected]> wrote:
> To do this, I need to add (to the class method's Overrides) the
> MethodReference pointing to MyInterface<string>.InterfaceMethod(). How
> do I get it?
static TypeReference MakeGenericType (TypeReference type, params
TypeReference [] arguments)
{
if (type.GenericParameters.Count != arguments.Length)
throw new ArgumentException();
var instance = new GenericInstanceType (type);
foreach (var argument in arguments)
instance.GenericArguments.Add (argument);
return instance;
}
static MethodReference MakeGeneric (MethodReference method,
TypeReference declaringType)
{
var reference = new MethodReference (method.Name, declaringType,
method.ReturnType.ReturnType, method.HasThis, method.ExplicitThis,
MethodCallingConvention.Generic);
foreach (var parameter in method.Parameters)
reference.Parameters.Add (new ParameterDefinition
(parameter.ParameterType));
return reference;
}
//
TypeReference my_iface_of_t = ...;
TypeReference string_ref;
TypeReference my_iface_of_string = MakeGenericType (my_iface_of_t, string_ref);
MethodReference my_iface_of_t_ifacemethod = ...;
MethodReference my_iface_of_string_ifacemethod = MakeGeneric
(my_iface_of_t_iface_method, my_iface_of_string);
--
Jb Evain <[email protected]>
--
--
mono-cecil
To unsubscribe from this group, send email to
mono-cecil+unsubscribegooglegroups.com or reply to this email with the words
"REMOVE ME" as the subject.