Пример #1
0
        /// <summary>
        /// Adds a CASRecord to the EncodingFile generating all required entries. This will overwrite existing entries
        /// </summary>
        /// <param name="record"></param>
        public void AddOrUpdate(CASRecord record)
        {
            // CKeyPageTable - overwrite existing
            var cKeyEntry = new EncodingContentEntry
            {
                CKey             = record.CKey,
                DecompressedSize = record.EBlock.DecompressedSize
            };

            cKeyEntry.EKey            = record.EKey;
            _CKeyEntries[record.CKey] = cKeyEntry;

            // EKeyPageTable - overwrite existing
            // get or add to the ESpecStringTable
            int especIndex = ESpecStringTable.IndexOf(record.ESpec);

            if (especIndex == -1)
            {
                especIndex = ESpecStringTable.Count - 2;
                ESpecStringTable.Insert(especIndex, record.ESpec);
            }

            // create the entry
            var eKeyEntry = new EncodingEncodedEntry()
            {
                CompressedSize = record.EBlock.CompressedSize,
                EKey           = record.EKey,
                ESpecIndex     = (uint)especIndex
            };

            _EKeyEntries[record.EKey] = eKeyEntry;
        }
Пример #2
0
        /// <summary>
        /// Adds a CASRecord to the EncodingFile generating all required entries. This will overwrite existing entries
        /// </summary>
        /// <param name="record"></param>
        public void AddOrUpdate(CASRecord record, TACTRepo tactRepo = null)
        {
            // CKeyPageTable
            Remove(record, tactRepo);
            var cKeyEntry = new EncodingContentEntry
            {
                CKey             = record.CKey,
                EKeys            = new List <MD5Hash>(),
                DecompressedSize = record.EBlock.DecompressedSize,
            };

            cKeyEntry.EKeys.Add(record.EKey);
            _CKeyEntries.Add(record.CKey, cKeyEntry);

            // get or add to the ESpecStringTable
            int especIndex = ESpecStringTable.IndexOf(record.ESpec);

            if (especIndex == -1)
            {
                especIndex = ESpecStringTable.Count - 2;
                ESpecStringTable.Insert(especIndex, record.ESpec);
            }

            // EKeyPageTable
            var eKeyEntry = new EncodingEncodedEntry()
            {
                CompressedSize = record.EBlock.CompressedSize,
                EKey           = record.EKey,
                ESpecIndex     = (uint)especIndex
            };

            _EKeyEntries[record.EKey] = eKeyEntry;

            // propogate the new record
            if (tactRepo != null)
            {
                tactRepo.IndexContainer?.Enqueue(record);
                tactRepo.DownloadFile?.AddOrUpdate(record);
                tactRepo.DownloadSizeFile?.AddOrUpdate(record);
            }
        }
Пример #3
0
        /// <summary>
        /// Adds a CASRecord to the EncodingFile generating all required entries. This will overwrite existing entries
        /// </summary>
        /// <param name="record"></param>
        public void AddOrUpdate(CASRecord record)
        {
            // CKeyPageTable
            if (_CKeyEntries.TryGetValue(record.CKey, out var cKeyEntry))
            {
                _EKeyEntries.Remove(cKeyEntry.EKey);
                cKeyEntry.EKey = record.EKey;
            }
            else
            {
                cKeyEntry = new EncodingContentEntry
                {
                    CKey             = record.CKey,
                    EKey             = record.EKey,
                    DecompressedSize = record.EBlock.DecompressedSize,
                };

                _CKeyEntries.Add(record.CKey, cKeyEntry);
            }

            // get or add to the ESpecStringTable
            int especIndex = ESpecStringTable.IndexOf(record.ESpec);

            if (especIndex == -1)
            {
                especIndex = ESpecStringTable.Count - 2;
                ESpecStringTable.Insert(especIndex, record.ESpec);
            }

            // EKeyPageTable
            var eKeyEntry = new EncodingEncodedEntry()
            {
                CompressedSize = record.EBlock.CompressedSize,
                EKey           = record.EKey,
                ESpecIndex     = (uint)especIndex
            };

            _EKeyEntries[record.EKey] = eKeyEntry;
        }
Пример #4
0
 /// <summary>
 /// Gets a EKeyEntry by it's Encoding Key
 /// </summary>
 /// <param name="ekey"></param>
 /// <param name="entry"></param>
 /// <returns></returns>
 public bool TryGetEKeyEntry(MD5Hash ekey, out EncodingEncodedEntry entry) => _EKeyEntries.TryGetValue(ekey, out entry);
Пример #5
0
 public void Remove(EncodingEncodedEntry entry)
 {
     _EKeyEntries.Remove(entry.EKey);
 }
Пример #6
0
 public void AddOrUpdate(EncodingEncodedEntry entry)
 {
     entry.Validate();
     _EKeyEntries[entry.EKey] = entry;
 }
Пример #7
0
 /// <summary>
 /// Removes an Encoding Entry
 /// <para>Note: CKeys and EKeys must have a 1:1 relationship</para>
 /// </summary>
 /// <param name="entry"></param>
 /// <returns></returns>
 public bool Remove(EncodingEncodedEntry entry)
 {
     return(entry == null || _EKeyEntries.Remove(entry.EKey));
 }