private static void LoadTableInfo(Table table, CFStorage rootStorage, CFStorage gameStorage) { // first, although we can loop through entries, get them from the game storage, so we // know their order, which is important when writing back (because you know, hashing). gameStorage.TryGetStream("CustomInfoTags", out var citStream); if (citStream != null) { using (var stream = new MemoryStream(citStream.GetData())) using (var reader = new BinaryReader(stream)) { table.CustomInfoTags = new CustomInfoTags(reader); } } // now actually read them in rootStorage.TryGetStorage("TableInfo", out var tableInfoStorage); if (tableInfoStorage == null) { Logger.Info("TableInfo storage not found, skipping."); return; } tableInfoStorage.VisitEntries(item => { if (item.IsStream) { var itemStream = item as CFStream; if (itemStream != null) { table.TableInfo[item.Name] = BiffUtil.ParseWideString(itemStream.GetData()); } } }, false); }
public static DataSpaceInfo?Load(CFStorage cfStorage) { if (cfStorage.TryGetStorage("DataSpaceInfo", out var storage)) { return(new DataSpaceInfo(storage)); } return(null); }
public static CFStorage GetOrAddStorage(this CFStorage storage, string storageName) { if (storage == null) { throw new ArgumentNullException(nameof(storage)); } return(storage.TryGetStorage(storageName, out var childStorage) ? childStorage : storage.AddStorage(storageName)); }
public static TransformInfo?Load(CFStorage cfStorage) { if (cfStorage.TryGetStorage("TransformInfo", out var storage)) { return(new TransformInfo(storage)); } return(null); }
private void ReadUniqueIdPrimitiveInformation(CFStorage componentStorage, PcbComponent component) { if (!componentStorage.TryGetStorage("UniqueIdPrimitiveInformation", out var uniqueIdPrimitiveInformation)) { return; } BeginContext("UniqueIdPrimitiveInformation"); try { var recordCount = ReadHeader(uniqueIdPrimitiveInformation); using (var reader = uniqueIdPrimitiveInformation.GetStream("Data").GetBinaryReader()) { uint actualRecordCount = 0; while (reader.BaseStream.Position < reader.BaseStream.Length) { var parameters = ReadBlock(reader, size => ReadParameters(reader, size)); var primitiveIndex = parameters["PRIMITIVEINDEX"].AsIntOrDefault(); var primitiveObjectId = parameters["PRIMITIVEOBJECTID"].AsStringOrDefault(); var uniqueId = parameters["UNIQUEID"].AsStringOrDefault(); if (!CheckValue("PRIMITIVEINDEX < Primitives.Count", primitiveIndex < component.Primitives.Count, true)) { return; } var primitive = component.Primitives[primitiveIndex]; if (!CheckValue(nameof(primitiveObjectId), primitiveObjectId, primitive.ObjectId.ToString())) { return; } primitive.UniqueId = uniqueId; actualRecordCount++; } AssertValue(nameof(actualRecordCount), actualRecordCount, recordCount); } } finally { EndContext(); } }