public static TypeDefinitionProjection RemoveProjection(TypeDefinition type)
{
if (!type.IsWindowsRuntimeProjection)
return null;
var projection = type.WindowsRuntimeProjection;
type.WindowsRuntimeProjection = null;
type.Attributes = projection.Attributes;
type.Name = projection.Name;
if (projection.Treatment == TypeDefinitionTreatment.RedirectImplementedMethods) {
foreach (var method in projection.RedirectedMethods) {
type.Methods.Remove (method);
}
foreach (var redirectedInterfacePair in projection.RedirectedInterfaces) {
foreach (var method in type.Methods) {
foreach (var @override in method.Overrides) {
if (TypeReferenceEqualityComparer.AreEqual (@override.DeclaringType, redirectedInterfacePair.Value.InterfaceType)) {
@override.DeclaringType = redirectedInterfacePair.Key.InterfaceType;
}
}
}
foreach (var customAttribute in redirectedInterfacePair.Value.CustomAttributes)
redirectedInterfacePair.Key.CustomAttributes.Add (customAttribute);
redirectedInterfacePair.Value.CustomAttributes.Clear ();
type.Interfaces.Remove (redirectedInterfacePair.Value);
}
}
return projection;
}