BTW I tried looking for the MethodCollection of generic and git fields:
TypeDefinition td =
this.GetTypeDefinition(AssemblyFactory.GetAssembly("C.dll"), "C.Tbase");
TypeReference fd = assembly.MainModule.Import(td);
TypeReference generic =
assembly.MainModule.Import(typeof(System.Func<>));
GenericInstanceType git = new GenericInstanceType(generic);
git.GenericArguments.Add(fd);
On Thu, May 29, 2008 at 2:13 AM, Jair Cazarin <[EMAIL PROTECTED]>
wrote:
> Hi guys,
>
> I've something like the following code inside a type:
>
> publoc void m()
> {
> new Text().DoSomething();
> }
>
> In IL its:
> nop
> newobj System.Void B.Text::ctor()
> stloc.0
> ldloc.0
> callvirt System.Void C:Tbase::DoSomething() //Because Text
> inherits from Tbase
> nop
>
> And I want to replace this instruction in order to have the following
> (TBaseFactory is property already defined):
>
> public void m()
> {
> TBaseFactory().DoSomething();
> }
>
> nop
> call System.Func'1<C.Tbase> A.Ta::get_TBaseFactory()
> callvirt !0 System.Func'1<C.Tbase>::Invoke()
> stloc.0
> ldloc.0
> callvirt System.Void C.Tbase::DoSomething()
> nop
> ret
>
> My problem is that I dont know how to create the highlighted instruction.
> Specifically I don't know where can I get the MethodReference for Invoke()
> of Func'1<C.Tbase>.
>
> Regards.
> --
> Jair Cazarin Villanueva
> http://jaircazarin.blogspot.com
--
Jair Cazarin Villanueva
http://jaircazarin.blogspot.com
--~--~---------~--~----~------------~-------~--~----~
--
mono-cecil
-~----------~----~----~----~------~----~------~--~---