Ejemplo n.º 1
0
        public static ConversionMap FromHashCollection(LeagueHashCollection col)
        {
            var result  = new ConversionMap();
            var mapping = new Dictionary <string, Dictionary <string, uint> >();

            foreach (var entry in col.Hashes)
            {
                var hash    = entry.Key;
                var section = entry.Value.First();
                var name    = section.Value.First();
                if (!mapping.ContainsKey(section.Key))
                {
                    mapping[section.Key] = new Dictionary <string, uint>();
                }
                mapping[section.Key].Add(name, hash);
            }

            foreach (var kvp in mapping)
            {
                foreach (var entry in kvp.Value)
                {
                    var key  = new InibinKey(kvp.Key, entry.Key);
                    var hash = entry.Value;
                    result.Add(key, hash);
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        public void AddByKey(InibinKey key, InibinValue value)
        {
            var hash = _conversionMap.GetHash(key);

            _hashToValue.Add(hash, value);
            _keyToValue.Add(key, value);
        }
Ejemplo n.º 3
0
 public uint GetHash(InibinKey key)
 {
     if (!_keyToHash.ContainsKey(key))
     {
         throw new NotSupportedException();
     }
     return(_keyToHash[key]);
 }
Ejemplo n.º 4
0
 public InibinKey GetKey(uint hash)
 {
     if (!_hashToKey.ContainsKey(hash))
     {
         var key = new InibinKey("UNKNOWN_HASHES", hash.ToString());
         _keyToHash.Add(key, hash);
         _hashToKey.Add(hash, key);
     }
     return(_hashToKey[hash]);
 }
Ejemplo n.º 5
0
        public static ConversionMap Load(string path)
        {
            var result = new ConversionMap();
            var map    = JsonConvert.DeserializeObject <Dictionary <string, Dictionary <string, uint> > >(File.ReadAllText(path));

            foreach (var kvp in map)
            {
                foreach (var entry in kvp.Value)
                {
                    var key  = new InibinKey(kvp.Key, entry.Key);
                    var hash = entry.Value;
                    result.Add(key, hash);
                }
            }
            return(result);
        }
Ejemplo n.º 6
0
 private void Add(InibinKey key, uint hash)
 {
     _keyToHash.Add(key, hash);
     _hashToKey.Add(hash, key);
 }