n//Create the
RAssemblyDef instance for the Teste3.exe assembly
nRAssemblyDef rAssembly =
RAssemblyDef.LoadAssembly("Teste3.exe");
n//Get the RType object
for the type that declares the methods
nRType rtd =
rAssembly.RModuleDef.GetType("FooBar");
n//Create a RParameter
object array
nRParameter [] paramsz = new
RParameter[1];
n//Set the first
element of the array
nparamsz[0] = new
RParameter(0,rAssembly.GetType("System.String"));
n//Get the method to
replace the original
nRMethodDef rmdReplacer = (RMethodDef)rtd.GetMethod("wrt",rAssembly.GetType("System.Void"),paramsz);
n//Get the original
method
nRMethodDef rmdOriginal = (RMethodDef)rtd.GetMethod("MyMethod",rAssembly.GetType("System.Void"),paramsz);
n//Create a
CodeTransformer object
nCodeTransformer cc = new
CodeTransformer();
n//Set the
transformation to make in the code
ncc.RedirectMethodCall(rmdOriginal,rmdReplacer);
n// Aplly the
transformation to all methods and constructors
n// in the in the
assembly
nrAssembly.Accept(cc);
n//Save the method
nrAssembly.SaveAssembly("Teste3.exe");