Example #1
0
        private void EnsureLoaded()
        {
            if (_aliases != null)
            {
                return;
            }

            if (!_paths.Exists(_paths.User.AliasesFile))
            {
                _aliases = new AliasModel();
                return;
            }

            string  sourcesText = _paths.ReadAllText(_paths.User.AliasesFile, "{}");
            JObject parsed      = JObject.Parse(sourcesText);
            IReadOnlyDictionary <string, IReadOnlyList <string> > commandAliases = parsed.ToStringListDictionary(StringComparer.OrdinalIgnoreCase, "CommandAliases");

            _aliases = new AliasModel(commandAliases);
        }
        private void EnsureLoaded()
        {
            if (_aliases != null)
            {
                return;
            }

            if (!_paths.Exists(_paths.User.AliasesFile))
            {
                _aliases = new AliasModel();
                return;
            }

            string  sourcesText = _paths.ReadAllText(_paths.User.AliasesFile, "{}");
            JObject parsed      = JObject.Parse(sourcesText);
            Dictionary <string, string> commandAliases = new Dictionary <string, string>();

            foreach (JProperty entry in parsed.PropertiesOf(nameof(_aliases.CommandAliases)))
            {
                commandAliases.Add(entry.Name, entry.Value.ToString());
            }

            _aliases = new AliasModel(commandAliases);
        }