コード例 #1
0
            private XmlNamespace CreateUri(IAssembly assembly, string clrNamespace)
            {
                StringBuilder stringBuilder = new StringBuilder("clr-namespace:");

                stringBuilder.Append(clrNamespace);
                string assemblyName = this.GetAssemblyName(assembly);

                if (!string.IsNullOrEmpty(assemblyName))
                {
                    stringBuilder.Append(';');
                    stringBuilder.Append("assembly=");
                    stringBuilder.Append(assemblyName);
                }
                return(XmlNamespace.ToNamespace(stringBuilder.ToString(), XmlNamespace.GetNamespaceCanonicalization(this.documentContext.TypeResolver)));
            }
コード例 #2
0
        public XmlNamespace GetXmlNamespace(ITextLocation lineInformation, IXmlNamespaceResolver xmlNamespaceResolver, XmlnsPrefix prefix)
        {
            XmlNamespace xmlNamespace = xmlNamespaceResolver.GetXmlNamespace(prefix, XmlNamespace.GetNamespaceCanonicalization(this.TypeResolver));

            if (xmlNamespace != null)
            {
                return(xmlNamespace);
            }
            if (prefix == XmlnsPrefix.EmptyPrefix)
            {
                this.ReportError(XamlParseErrors.NoDefaultNamespace(lineInformation));
            }
            else
            {
                this.ReportError(XamlParseErrors.UnrecognizedXmlnsPrefix(lineInformation, prefix));
            }
            return(XmlNamespace.AvalonXmlNamespace);
        }
コード例 #3
0
 public static ITypeId SniffRootNodeType(Stream stream, IDocumentContext documentContext, out string xamlClassAttribute)
 {
     xamlClassAttribute = (string)null;
     try
     {
         ITypeResolver typeResolver = documentContext.TypeResolver;
         using (XmlReader xmlReader = XmlReader.Create(stream))
         {
             ClrNamespaceUriParseCache documentNamespaces = new ClrNamespaceUriParseCache(typeResolver);
             while (xmlReader.Read())
             {
                 if (xmlReader.MoveToContent() == XmlNodeType.Element)
                 {
                     xamlClassAttribute = xmlReader.GetAttribute("Class", "http://schemas.microsoft.com/winfx/2006/xaml");
                     string str = xmlReader.LookupNamespace(xmlReader.Prefix);
                     if (!string.IsNullOrEmpty(str))
                     {
                         return((ITypeId)XamlTypeHelper.GetTypeId(typeResolver, documentNamespaces, XmlNamespace.ToNamespace(str, XmlNamespace.GetNamespaceCanonicalization(typeResolver)), xmlReader.LocalName, false, false));
                     }
                 }
             }
         }
     }
     catch (XmlException ex)
     {
     }
     return((ITypeId)null);
 }
コード例 #4
0
        private static bool IsTypeInXmlNamespace(IProjectContext project, IType type, string xmlNamespaceString)
        {
            if (project == null || project.ProjectNamespaces == null)
            {
                return(false);
            }
            IXmlNamespace @namespace   = project.ProjectNamespaces.GetNamespace(type.RuntimeAssembly, type.Namespace);
            IXmlNamespace xmlNamespace = (IXmlNamespace)XmlNamespace.ToNamespace(xmlNamespaceString, XmlNamespace.GetNamespaceCanonicalization((ITypeResolver)project));

            return(@namespace != null && @namespace.Value == xmlNamespace.Value);
        }
コード例 #5
0
        public ICodeAidTypeInfo GetTypeByName(string uri, string typeName)
        {
            IProjectContext projectContext = this.ProjectContext;
            IXmlNamespace   xmlNamespace   = (IXmlNamespace)XmlNamespace.ToNamespace(uri, XmlNamespace.GetNamespaceCanonicalization((ITypeResolver)projectContext));

            if (xmlNamespace == null)
            {
                return((ICodeAidTypeInfo)null);
            }
            IType type = projectContext.GetType(xmlNamespace, typeName);

            if (type != null)
            {
                return((ICodeAidTypeInfo) new CodeAidTypeInfo(this, type));
            }
            return((ICodeAidTypeInfo)null);
        }