What can we really do with RAIL?
n//Create the RAssemblyDef objects of the two assemblies
nRAssemblyDef rAssembly = RAssemblyDef.LoadAssembly("Teste.exe");
nRAssemblyDef rAssembly2 = RAssemblyDef.LoadAssembly("Teste2.dll");
n//Get the type to copy from assembly Teste2.dll to assembly Teste.exe
nRType typeToCopy = rAssembly2.RModuleDef.GetType("Bar");
n//Copies the type Bar to Teste.exe assembly
nrAssembly.RModuleDef.CopyType(typeToCopy,typeToCopy.Name);
n//Creates the RType instances of the to types
nRType oldType = rAssembly.RModuleDef.GetType("Foo");
nRType newType = rAssembly.RModuleDef.GetType("Bar");
n//Creates the ReferenceReplacer visitor object
nReferenceReplacer rr = new ReferenceReplacer(oldType,newType);
n//Aplly the change to the assembly an its members
nrAssembly.Accept(rr);
n//Remove the previous used type Foo
nrAssembly.RModuleDef.RemoveType("Foo");
n//Save the new assembly
nrAssembly.SaveAssembly("Teste.exe");
Replace References