Ejemplo n.º 1
0
        string IRegistryOptions.GetFilePath(string scopeName)
        {
            foreach (string grammarName in _availableGrammars.Keys)
            {
                GrammarDefinition definition = _availableGrammars[grammarName];

                foreach (Grammar grammar in definition.Contributes.Grammars)
                {
                    if (scopeName.Equals(grammar.ScopeName))
                    {
                        string grammarPath = grammar.Path;

                        if (grammarPath.StartsWith("./"))
                        {
                            grammarPath = grammarPath.Substring(2);
                        }

                        grammarPath = grammarPath.Replace("/", ".");

                        return(grammarName.ToLower() + "." + grammarPath);
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 2
0
        void InitializeGrammars()
        {
            var serializer = new JsonSerializer();

            foreach (string grammar in GrammarNames.SupportedGrammars)
            {
                using (Stream stream = ResourceLoader.OpenGrammarPackage(grammar))
                    using (StreamReader reader = new StreamReader(stream))
                        using (JsonTextReader jsonTextReader = new JsonTextReader(reader))
                        {
                            GrammarDefinition definition = serializer.Deserialize <GrammarDefinition>(jsonTextReader);
                            _availableGrammars.Add(grammar, definition);
                        }
            }
        }