Ejemplo n.º 1
0
 public void Register(HighlightingManager manager)
 {
     manager.RegisterHighlighting(
         this.Name, this.Extensions, delegate {
         return(HighlightingLoader.Load(LoadXshd(), manager));
     });
 }
        private IHighlightingDefinition LoadHighlightingDefinition()
        {
            HighlightingManager highlightingManager = HighlightingManager.Instance;

            if (!string.IsNullOrEmpty(CustomSyntaxHighlightingFileName))
            {
                using var reader  = new XmlTextReader(OpenStream(CustomSyntaxHighlightingFileName));
                _syntaxDefinition = HighlightingLoader.LoadXshd(reader);
            }

            if (_syntaxDefinition != null)
            {
                var highlightingDefinition = HighlightingLoader.Load(_syntaxDefinition, highlightingManager);
                highlightingManager.RegisterHighlighting(_syntaxDefinition.Name, _syntaxDefinition.Extensions.ToArray(), highlightingDefinition);
            }

            return(highlightingManager.GetDefinition(Name));
        }
Ejemplo n.º 3
0
        private HighlightingManager getHighlightingManager(Themes theme, string dirName)
        {
            var hlm = new HighlightingManager();

            var assemblyPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            if (string.IsNullOrEmpty(assemblyPath))
            {
                return(hlm);
            }

            var syntaxPath = Path.Combine(assemblyPath, "Syntax", dirName);

            if (!Directory.Exists(syntaxPath))
            {
                return(hlm);
            }

            foreach (var file in Directory.EnumerateFiles(syntaxPath, "*.xshd"))
            {
                Debug.WriteLine(file);
                var ext = Path.GetFileNameWithoutExtension(file);
                using (Stream s = File.OpenRead(Path.GetFullPath(file)))
                    using (var reader = new XmlTextReader(s))
                    {
                        var xshd = HighlightingLoader.LoadXshd(reader);
                        var highlightingDefinition = HighlightingLoader.Load(xshd, hlm);
                        if (xshd.Extensions.Count > 0)
                        {
                            hlm.RegisterHighlighting(ext, xshd.Extensions.ToArray(), highlightingDefinition);
                        }
                    }
            }

            return(hlm);
        }