/// <summary>
        /// Gets the namespace prefix that is associated with the
        /// specified file extension.
        /// </summary>
        public static string GetNamespacePrefixForFileName(string filename)
        {
            var association = XmlFileAssociationManager.GetAssociationForFileName(filename);

            if (association != null)
            {
                return(association.NamespacePrefix);
            }
            return(String.Empty);
        }
示例#2
0
        /// <summary>
        /// Gets the namespace prefix that is associated with the
        /// specified file extension.
        /// </summary>
        public static string GetNamespacePrefix(string extension)
        {
            var association = XmlFileAssociationManager.GetAssociation(extension);

            if (association != null)
            {
                return(association.NamespacePrefix);
            }
            return(String.Empty);
        }
示例#3
0
        /// <summary>
        /// Determines whether the file can be displayed by
        /// the xml editor.
        /// </summary>
        public static bool IsFileNameHandled(string fileName)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                return(false);
            }

            string mimeType = DesktopService.GetMimeTypeForUri(fileName);

            if (IsMimeTypeHandled(mimeType))
            {
                return(true);
            }

            return(XmlFileAssociationManager.IsXmlFileName(fileName));
        }
示例#4
0
        /// <summary>
        /// Determines whether the file can be displayed by
        /// the xml editor.
        /// </summary>
        public static bool IsFileNameHandled(string fileName)
        {
            if (fileName == null)
            {
                return(false);
            }
            if (System.IO.Path.IsPathRooted(fileName))
            {
                string vfsname  = fileName.Replace("%", "%25").Replace("#", "%23").Replace("?", "%3F");
                string mimeType = DesktopService.GetMimeTypeForUri(vfsname);
                if (IsMimeTypeHandled(mimeType))
                {
                    return(true);
                }
            }

            return(XmlFileAssociationManager.IsXmlFileExtension(System.IO.Path.GetExtension(fileName)));
        }
        /// <summary>
        /// Determines whether the file can be displayed by
        /// the xml editor.
        /// </summary>
        public static bool IsFileNameHandled(string fileName)
        {
            if (fileName == null)
            {
                return(false);
            }
            // HACK: Bug 4747 - No code completion for unsaved XML files
//			if (System.IO.Path.IsPathRooted (fileName)) {
            string vfsname  = fileName.Replace("%", "%25").Replace("#", "%23").Replace("?", "%3F");
            string mimeType = DesktopService.GetMimeTypeForUri(vfsname);

            if (IsMimeTypeHandled(mimeType))
            {
                return(true);
            }
//			}

            return(XmlFileAssociationManager.IsXmlFileName(fileName));
        }
        public static XmlSchemaCompletionData GetSchemaCompletionDataForFileName(string filename)
        {
            var association = XmlFileAssociationManager.GetAssociationForFileName(filename);

            if (association == null || association.NamespaceUri.Length == 0)
            {
                return(null);
            }
            var u = new Uri(association.NamespaceUri);

            if (u.IsFile)
            {
                return(ReadLocalSchema(u));
            }
            else
            {
                return(SchemaCompletionDataItems [association.NamespaceUri]);
            }
        }