コード例 #1
0
        public static IEnumerable <string> GetExtensions()
        {
            if (extensions == null)
            {
                extensions = new List <string> ();
                foreach (ExtensionNode node in AddinManager.GetExtensionNodes("/MonoDevelop/XmlEditor/XmlFileExtensions"))
                {
                    XmlFileExtensionNode xmlFileExtensionNode = node as XmlFileExtensionNode;
                    if (xmlFileExtensionNode != null)
                    {
                        extensions.Add(xmlFileExtensionNode.FileExtension.ToLowerInvariant());
                    }
                }
            }

            //get user-registered extensions stored in the properties service but don't duplicate built-in ones
            //note: XmlEditorAddInOptions returns LowerInvariant strings
            foreach (string prop in XmlEditorOptions.GetRegisteredFileExtensions())
            {
                if (!extensions.Contains(prop))
                {
                    yield return(prop);
                }
            }

            foreach (string s in extensions)
            {
                yield return(s);
            }
        }
コード例 #2
0
        /// <summary>
        /// Gets the namespace prefix that is associated with the
        /// specified file extension.
        /// </summary>
        public static string GetNamespacePrefix(string extension)
        {
            var association = XmlEditorOptions.GetSchemaAssociation(extension);

            if (association != null)
            {
                return(association.NamespacePrefix);
            }
            return(String.Empty);
        }
コード例 #3
0
        public static bool IsXmlFileExtension(string extension)
        {
            if (string.IsNullOrEmpty(extension))
            {
                return(false);
            }

            if (map.ContainsKey(extension))
            {
                return(true);
            }

            return(XmlEditorOptions.GetFileAssociation(extension) != null);
        }
コード例 #4
0
        public static XmlFileAssociation GetAssociation(string extension)
        {
            var assoc = XmlEditorOptions.GetFileAssociation(extension);

            if (assoc != null)
            {
                return(assoc);
            }
            if (map.TryGetValue(extension, out assoc))
            {
                return(assoc);
            }
            return(null);
        }
コード例 #5
0
        /// <summary>File extensions that have XML associations.</summary>
        /// <returns>LowerInvariant file extensions.</returns>
        public static IEnumerable <string> GetExtensions()
        {
            foreach (string prop in XmlEditorOptions.GetFileExtensions())
            {
                if (!map.ContainsKey(prop))
                {
                    yield return(prop);
                }
            }

            foreach (var item in map)
            {
                yield return(item.Key);
            }
        }
コード例 #6
0
        public static XmlSchemaCompletionData GetSchemaCompletionData(string fileExtension)
        {
            XmlSchemaCompletionData data = null;

            var association = XmlEditorOptions.GetSchemaAssociation(fileExtension);

            if (association != null)
            {
                if (association.NamespaceUri.Length > 0)
                {
                    data = SchemaCompletionDataItems [association.NamespaceUri];
                }
            }

            return(data);
        }
コード例 #7
0
 public static XmlFileAssociation GetAssociationForFileName(string filename)
 {
     foreach (var extension in GetFileExtensions(filename))
     {
         var assoc = XmlEditorOptions.GetFileAssociation(extension);
         if (assoc != null)
         {
             return(assoc);
         }
         if (map.TryGetValue(extension, out assoc))
         {
             return(assoc);
         }
     }
     return(null);
 }
コード例 #8
0
        public static IEnumerable <XmlFileAssociation> GetAssociations()
        {
            var returned = new HashSet <string> ();

            foreach (var assoc in XmlEditorOptions.GetFileAssociations())
            {
                returned.Add(assoc.Extension);
                yield return(assoc);
            }

            foreach (var item in map)
            {
                if (!returned.Contains(item.Key))
                {
                    yield return(item.Value);
                }
            }
        }
コード例 #9
0
        public static bool IsXmlFileName(string filename)
        {
            foreach (var extension in GetFileExtensions(filename))
            {
                if (string.IsNullOrEmpty(extension))
                {
                    return(false);
                }

                if (map.ContainsKey(extension))
                {
                    return(true);
                }

                if (XmlEditorOptions.GetFileAssociation(extension) != null)
                {
                    return(true);
                }
            }

            return(false);
        }