Beispiel #1
0
 /// <summary>
 /// Sets a global alias
 /// </summary>
 public void Set(GlobalAlias alias)
 {
     lock (_lock)
     {
         UserAliases.SetOrAdd(alias.Keyword, alias.Value);
         UserAliasesChanged?.Invoke(this, EventArgs.Empty);
     }
 }
Beispiel #2
0
 /// <summary>
 /// Removes a global alias by keyword
 /// </summary>
 public void Remove(string keyword)
 {
     keyword = keyword.ToUpperInvariant().Trim();
     lock (_lock)
     {
         UserAliases.Remove(keyword);
         UserAliasesChanged?.Invoke(this, EventArgs.Empty);
     }
 }
Beispiel #3
0
 /// <summary>
 /// Populates global aliases from a list
 /// </summary>
 public void Populate(IEnumerable <GlobalAlias> globalAliases)
 {
     lock (_lock)
     {
         UserAliases.Clear();
         foreach (var alias in globalAliases)
         {
             Set(alias);
         }
         UserAliasesChanged?.Invoke(this, EventArgs.Empty);
     }
 }
Beispiel #4
0
        /// <summary>
        /// Loads global aliases from file
        /// </summary>
        public void Load()
        {
            if (!File.Exists(FileSystem.AliasFilePath))
            {
                return;
            }

            lock (_lock)
            {
                string data = File.ReadAllText(FileSystem.AliasFilePath);
                UserAliases = JsonConvert.DeserializeObject <Dictionary <string, string> >(data);
                UserAliasesChanged?.Invoke(this, EventArgs.Empty);
            }
        }