Example #1
0
        internal static IType GetTypeId(XamlParserContext parserContext, ITextLocation lineInformation, XmlNamespace xmlNamespace, string typeName, bool inMarkupExtension)
        {
            if (string.IsNullOrEmpty(typeName))
            {
                parserContext.ReportError(XamlParseErrors.MissingTypeName(lineInformation));
                return((IType)null);
            }
            if (typeName.IndexOf('.') >= 0)
            {
                parserContext.ReportError(XamlParseErrors.InnerTypesNotSupported(lineInformation, typeName));
                return((IType)null);
            }
            IType typeId = XamlTypeHelper.GetTypeId(parserContext.TypeResolver, parserContext.DocumentNamespaces, xmlNamespace, typeName, true, inMarkupExtension);

            if (typeId != null && typeId.IsResolvable)
            {
                if (!parserContext.TypeResolver.InTargetAssembly(typeId) && !TypeHelper.IsSet(MemberAccessTypes.Public, typeId.Access))
                {
                    parserContext.ReportError(XamlParseErrors.InaccessibleType(lineInformation, typeName));
                    return((IType)null);
                }
            }
            else if (xmlNamespace == XmlNamespace.AvalonXmlNamespace || xmlNamespace == XmlNamespace.XamlXmlNamespace)
            {
                parserContext.ReportError(XamlParseErrors.UnrecognizedPlatformTypeName(lineInformation, !parserContext.TypeResolver.IsCapabilitySet(PlatformCapability.IsWpf), typeName));
            }
            else
            {
                parserContext.ReportError(XamlParseErrors.UnrecognizedTypeName(lineInformation, xmlNamespace, typeName));
            }
            return(typeId);
        }