本文整理匯總了C#中Mono.Cecil.TypeDefinition.Clone方法的典型用法代碼示例。如果您正苦於以下問題:C# TypeDefinition.Clone方法的具體用法?C# TypeDefinition.Clone怎麽用?C# TypeDefinition.Clone使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mono.Cecil.TypeDefinition
的用法示例。
在下文中一共展示了TypeDefinition.Clone方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: VisitTypeDefinition
public override void VisitTypeDefinition (TypeDefinition type)
{
if (type.Name == Context.MainTypeName) {
bool clone = (type != Context.MainType);
Console.WriteLine ("Found main type in assembly {0}. clone is {1}", type.Module.Assembly.Name.Name, clone);
foreach (MethodDefinition method in type.Methods) {
MethodDefinition md = Context.InternalSymbols.InsertMethod (method, clone);
if (md != null) {
if (clone) {
Context.MainType.Methods.Add (md);
}
} else {
Context.LinkFailed = true;
}
}
foreach (FieldDefinition field in type.Fields) {
FieldDefinition fd = Context.InternalSymbols.InsertField (field, clone);
if (fd != null) {
if (clone) {
Context.MainType.Fields.Add (fd);
}
} else {
Context.LinkFailed = true;
}
}
} else if (!Target.MainModule.Types.Contains (type) && type.DeclaringType == null) {
//not nested
TypeDefinition td = type.Clone ();
Target.MainModule.Types.Add (td);
foreach (TypeDefinition nested in td.NestedTypes)
Target.MainModule.Types.Add (nested);
}
}
示例2: VisitTypeDefinition
public override void VisitTypeDefinition (TypeDefinition type)
{
if (!Target.MainModule.Types.Contains (type) && type.DeclaringType == null)
AddTypeDefinition (type.Clone ());
}
示例3: addType
public void addType(TypeDefinition typeToAdd)
{
mainModule.Types.Add(typeToAdd.Clone());
}