Пример #1
0
        private AliasListing Load()
        {
            var version = ReadByte();

            switch (version)
            {
            case 1:
            {
                IntSize = ReadByte();
                var count = ReadInt();

                var listing = new AliasListing();

                for (var i = 0; i < count; i++)
                {
                    var alias = ReadString();
                    var id    = ReadString();
                    listing[alias] = id;
                }

                CheckFullyRead();
                return(listing);
            }

            default:
                throw new InvalidOperationException($"Unsupported key version: {version}");
            }
        }
Пример #2
0
 private void Save(AliasListing listing)
 {
     WriteByte(CurrentVersion);
     WriteByte(SystemIntSize);
     WriteInt(listing.Count);
     foreach (var alias in listing.Keys)
     {
         WriteString(alias);
         WriteString(listing[alias]);
     }
 }
Пример #3
0
 private void Remove(AliasListing listing, string alias)
 {
     listing.Remove(alias);
     Save(listing);
 }
Пример #4
0
 private void Add(AliasListing listing, KeyAlias key)
 {
     listing[key.Alias] = key.Id;
     Save(listing);
 }