void CopyTo(CustomAttribute target, ModuleDefinition context) { foreach (var arg in ConstructorArguments) target.ConstructorArguments.Add(new CustomAttributeArgument(context.Import(arg.Type), arg.Value)); foreach (var field in Fields) target.Fields.Add(new CustomAttributeNamedArgument(field.Name, new CustomAttributeArgument(context.Import(field.Argument.Type), field.Argument.Value))); foreach (var prop in Properties) target.Properties.Add(new CustomAttributeNamedArgument(prop.Name, new CustomAttributeArgument(context.Import(prop.Argument.Type), prop.Argument.Value))); }
internal static CustomAttribute Clone(CustomAttribute custattr, ModuleDefinition context) { var ca = new CustomAttribute(context.Import(custattr.Constructor)); custattr.CopyTo(ca, context); return ca; }
private static MethodReference FixMethodImport(ModuleDefinition context, MethodDefinition source, MethodDefinition target, MethodReference method) { if (method.DeclaringType.FullName == source.DeclaringType.FullName) return FindMatchingMethod(target.DeclaringType, method); return context.Import(method); }
private static TypeReference FixTypeImport(ModuleDefinition context, MethodDefinition source, MethodDefinition target, TypeReference type) { if (type.FullName == source.DeclaringType.FullName) return target.DeclaringType; return context.Import(type); }
private static FieldReference FixFieldImport(ModuleDefinition context, MethodDefinition source, MethodDefinition target, FieldReference field) { if (field.DeclaringType.FullName == source.DeclaringType.FullName) return FindMatchingField(target.DeclaringType, field); return context.Import(field); }