Example #1
0
        public override void ApplyChanges()
        {
            if (widget.IsChanged)
            {
                try {
                    //need to remove then add, in case we're replacing
                    RemoveUserSchemas();
                    AddUserSchemas();

                    // Update schema associations after we have added any new schemas to the schema manager.
                    foreach (string extension in widget.RemovedExtensions)
                    {
                        XmlEditorOptions.RemoveFileAssociation(extension);
                    }
                    foreach (var item in widget.GetChangedXmlFileAssociations())
                    {
                        XmlEditorOptions.SetFileAssociation(item);
                    }
                } catch (Exception ex) {
                    string msg = MonoDevelop.Core.GettextCatalog.GetString(
                        "Unhandled error saving schema changes.");
                    MonoDevelop.Core.LoggingService.LogError(msg, ex);
                    MonoDevelop.Ide.MessageService.ShowException(ex, msg);
                    return;
                }
            }
        }
Example #2
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);
            }
        }
Example #3
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);
 }
Example #4
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);
                }
            }
        }
Example #5
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);
        }