internal void LoadBlocks(int currentBlock, long collectionOffset, DependencyReader reader) { if (blockCount == 0) { return; } var structdef = metadata.StructureDefinitions.First(s => s.FieldBlock == currentBlock && s.FieldOffset == collectionOffset); if (structdef.TargetIndex < 0) { return; } var block = metadata.DataBlocks[structdef.TargetIndex]; var blockSize = FixedSizeAttribute.ValueFor(typeof(T)); reader.Seek(block.Offset, SeekOrigin.Begin); for (int i = 0; i < blockCount; i++) { Add(reader.ReadObject <T>()); } var blockProps = typeof(T).GetProperties() .Where(p => p.PropertyType.IsGenericType && p.PropertyType.GetGenericTypeDefinition() == typeof(BlockCollection <>)); int index = 0; foreach (var item in this) { var adjustedBase = blockSize * index++; foreach (var prop in blockProps) { var collection = prop.GetValue(item) as IBlockCollection; var offset = OffsetAttribute.ValueFor(prop); collection.LoadBlocks(structdef.TargetIndex, adjustedBase + offset, reader); } } }
public static IAttrSet FixedSize(this IAttrSet attrSet, bool value) { FixedSizeAttribute a = new FixedSizeAttribute(value); return(attrSet.Add(a)); }
public static int GetHeaderSize(this Gen3.IGen3CacheFile cache) { return((int)FixedSizeAttribute.ValueFor(cache.Header.GetType(), (int)cache.CacheType)); }
public void TestFixedSizeValue() { Assert.AreEqual(128, FixedSizeAttribute.ValueFor(typeof(DataClass01))); Assert.AreEqual(256, FixedSizeAttribute.ValueFor(typeof(DataClass01), 15)); Assert.AreEqual(512, FixedSizeAttribute.ValueFor(typeof(DataClass01), 25)); }