Beispiel #1
0
        internal void LoadCache()
        {
            if (cacheLoaded)
            {
                return;
            }

            try
            {
                string savePathDir = GetCachePath();

                if (!File.Exists(savePathDir))
                {
                    cacheLoaded = true; // Just so it wont keep calling this over and over again.
                    return;
                }

                string[] allText = File.ReadAllLines(savePathDir);

                foreach (string line in allText)
                {
                    string[] split = line.Split(':');
                    string   name  = split[0];
                    string   index = split[1];

                    var cache = new EnumTypeCache()
                    {
                        Name  = name,
                        Index = int.Parse(index)
                    };

                    cacheList.Add(cache);
                }
            }
            catch (Exception exception)
            {
                Logger.Error($"Caught exception while reading cache!{Environment.NewLine}{exception}");
            }

            cacheLoaded = true;
        }
Beispiel #2
0
 public void Add(T value, EnumTypeCache entry)
 {
     HashedKeys.Add(value);
     customEnumTypes.Add(value, entry);
     customEnumNames.Add(entry.Name, value);
 }
Beispiel #3
0
 public bool TryGetValue(T key, out EnumTypeCache value) => customEnumTypes.TryGetValue(key, out value);