public static TypeReferenceProjection RemoveProjection(TypeReference type)
        {
            if (!type.IsWindowsRuntimeProjection)
            {
                return(null);
            }

            TypeReferenceProjection projection = type.WindowsRuntimeProjection;

            type.WindowsRuntimeProjection = null;

            type.Name      = projection.Name;
            type.Namespace = projection.Namespace;
            type.Scope     = projection.Scope;

            return(projection);
        }
        private static bool ImplementsRedirectedInterface(MemberReference member)
        {
            TypeReference declaring_type = member.DeclaringType;
            TypeReference type;

            switch (declaring_type.MetadataToken.TokenType)
            {
            case TokenType.TypeRef:
                type = declaring_type;
                break;

            case TokenType.TypeSpec:
                if (!declaring_type.IsGenericInstance)
                {
                    return(false);
                }

                type = ((TypeSpecification)declaring_type).ElementType;
                if (type.MetadataType != MetadataType.Class || type.MetadataToken.TokenType != TokenType.TypeRef)
                {
                    return(false);
                }

                break;

            default:
                return(false);
            }

            TypeReferenceProjection projection = RemoveProjection(type);

            bool found = false;

            if (Projections.TryGetValue(type.Name, out ProjectionInfo info) && type.Namespace == info.WinRTNamespace)
            {
                found = true;
            }

            ApplyProjection(type, projection);

            return(found);
        }
        public static void ApplyProjection(TypeReference type, TypeReferenceProjection projection)
        {
            if (projection == null)
            {
                return;
            }

            switch (projection.Treatment)
            {
            case TypeReferenceTreatment.SystemDelegate:
            case TypeReferenceTreatment.SystemAttribute:
                type.Scope = type.Module.Projections.GetAssemblyReference("System.Runtime");
                break;

            case TypeReferenceTreatment.UseProjectionInfo:
                ProjectionInfo info = Projections[type.Name];
                type.Name      = info.ClrName;
                type.Namespace = info.ClrNamespace;
                type.Scope     = type.Module.Projections.GetAssemblyReference(info.ClrAssembly);
                break;
            }

            type.WindowsRuntimeProjection = projection;
        }
        private static bool IsRedirectedType(TypeReference type)
        {
            TypeReferenceProjection typeRefProjection = type.GetElementType().projection as TypeReferenceProjection;

            return(typeRefProjection != null && typeRefProjection.Treatment == TypeReferenceTreatment.UseProjectionInfo);
        }