Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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;
        }
Ejemplo n.º 4
0
        private static bool IsRedirectedType(TypeReference type)
        {
            TypeReferenceProjection typeRefProjection = type.GetElementType().projection as TypeReferenceProjection;

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