private TGIBlockList ReadTGIBlock(BinaryReader r, EventHandler handler, TGIBlock.Order order = TGIBlock.Order.ITG) { int count = r.ReadInt32() / 4; List <TGIBlock> tgiblockList = new List <TGIBlock>(count); for (int i = 0; i < count; i++) { ulong instance = 0; uint type = 0; uint group = 0; if (order == TGIBlock.Order.ITG) { instance = r.ReadUInt64(); instance = (instance << 32) | (instance >> 32); // swap instance type = r.ReadUInt32(); group = r.ReadUInt32(); } else if (order == TGIBlock.Order.TGI) { type = r.ReadUInt32(); group = r.ReadUInt32(); instance = r.ReadUInt64(); instance = (instance << 32) | (instance >> 32); // swap instance } tgiblockList.Add(new TGIBlock(recommendedApiVersion, handler, type, group, instance)); } TGIBlockList result = new TGIBlockList(handler, tgiblockList); return(result); }
private void WriteTGIBlock(BinaryWriter w, TGIBlockList value, TGIBlock.Order order = TGIBlock.Order.ITG) { w.Write(value.Count * 4); foreach (var tgi in value) { ulong instance = (tgi.Instance << 32) | (tgi.Instance >> 32); if (order == TGIBlock.Order.ITG) { w.Write(instance); w.Write(tgi.ResourceType); w.Write(tgi.ResourceGroup); } else if (order == TGIBlock.Order.TGI) { w.Write(tgi.ResourceType); w.Write(tgi.ResourceGroup); w.Write(instance); } } }
/// <summary> /// Initializes a new instance of the <see cref="CountedTGIBlockList" /> class /// filled with <paramref name="count" /> elements from <see cref="System.IO.Stream" /> <paramref name="s" /> /// with the specified <see cref="TGIBlock.Order" />. /// </summary> /// <param name="handler">The <see cref="EventHandler" /> to call on changes to the list or its elements.</param> /// <param name="order">The <see cref="TGIBlock.Order" /> of the <see cref="TGIBlock" /> values.</param> /// <param name="count">The number of list elements to read.</param> /// <param name="s">The <see cref="System.IO.Stream" /> to read for the initial content of the list.</param> /// <param name="size">Optional; -1 for unlimited size, otherwise the maximum number of elements in the list.</param> public CountedTGIBlockList(EventHandler handler, TGIBlock.Order order, int count, Stream s, long size = -1) : this(handler, "" + order, count, s, size) { }
/// <summary> /// Initializes a new instance of the <see cref="CountedTGIBlockList" /> class /// filled with the content of <paramref name="ilt" /> /// with the specified <see cref="TGIBlock.Order" />. /// </summary> /// <param name="handler">The <see cref="EventHandler" /> to call on changes to the list or its elements.</param> /// <param name="order">The <see cref="TGIBlock.Order" /> of the <see cref="TGIBlock" /> values.</param> /// <param name="ilt">The <see cref="IEnumerable{TGIBlock}" /> to use as the initial content of the list.</param> /// <param name="size">Optional; -1 for unlimited size, otherwise the maximum number of elements in the list.</param> public CountedTGIBlockList(EventHandler handler, TGIBlock.Order order, IEnumerable <TGIBlock> ilt, long size = -1) : this(handler, "" + order, ilt, size) { }
/// <summary> /// Initializes a new instance of the <see cref="CountedTGIBlockList" /> class /// that is empty /// with the specified <see cref="TGIBlock.Order" />. /// </summary> /// <param name="handler">The <see cref="EventHandler" /> to call on changes to the list or its elements.</param> /// <param name="order">The <see cref="TGIBlock.Order" /> of the <see cref="TGIBlock" /> values.</param> /// <param name="size">Optional; -1 for unlimited size, otherwise the maximum number of elements in the list.</param> public CountedTGIBlockList(EventHandler handler, TGIBlock.Order order, long size = -1) : this(handler, "" + order, size) { }
// BYTE count // ITG resourcekey public StyleList(EventHandler handler, TGIBlock.Order o, int count, Stream s) : base(handler, TGIBlock.Order.ITG, count, s, 255) { }