public async Task AddReadItemAsync(ReadItem readItem, CancellationToken cancellationToken = default) { if (readItem == null) { return; } if (string.IsNullOrEmpty(readItem.Id)) { readItem.Id = StringUtil.GenerateRandom(); } var existingReadItems = await GetReadItemsAsync(readItem.StartTime.Year, cancellationToken) ?? new List <ReadItem>(); var allReadItems = await GetReadItemsAsync(cancellationToken); if (allReadItems.FirstOrDefault(x => StringUtil.EqualsIgnoreCase(x.Id, readItem.Id)) != null) { throw new Exception($"ReadItem with Id \"{readItem.Id}\" already exists."); } if (allReadItems.FirstOrDefault(x => x.BookName == readItem.BookName) != null) { _logger.LogWarning( $"It appears you already added same book before: {readItem.BookName}, however it's allowed."); } readItem.LastUpdateTime = DateTime.Now; existingReadItems.Add(readItem); await _readFileRepository.WriteAsync($"{readItem.StartTime.Year:D4}.json", JsonUtil.Serialize(existingReadItems, true), cancellationToken); }
public async Task UpdateReadItemAsync(ReadItem readItem, CancellationToken cancellationToken = default) { if (readItem == null) { return; } var existingReadItems = await GetReadItemsAsync(readItem.StartTime.Year, cancellationToken); if (existingReadItems == null) { throw new Exception($"ReadItems at year \"{readItem.StartTime.Year}\" not exist."); } var existingBookItem = existingReadItems.FirstOrDefault(x => StringUtil.EqualsIgnoreCase(x.Id, readItem.Id)); if (existingBookItem == null) { throw new Exception($"ReadItem with Id \"{readItem.Id}\" not exist."); } readItem.LastUpdateTime = DateTime.Now; existingReadItems.Remove(existingBookItem); existingReadItems.Add(readItem); await _readFileRepository.WriteAsync($"{readItem.StartTime.Year:D4}.json", JsonUtil.Serialize(existingReadItems, true), cancellationToken); }
private ReadItem ResolveRecord(RecordSchema schema) { ReadItem recordReader; if (!_recordReaders.TryGetValue(schema, out recordReader)) { lock (_recordReaders) { if (!_recordReaders.TryGetValue(schema, out recordReader)) { RecordAccess recordAccess = GetRecordAccess(schema); var fieldReaders = new List <FieldReader>(); recordReader = (r, d) => ReadRecord(r, d, recordAccess, fieldReaders); _recordReaders.Add(schema, recordReader); foreach (Field f in schema) { Field field = f; ReadItem readItem = ResolveReader(field.Schema); if (IsReusable(field.Schema.Type)) { fieldReaders.Add((rec, d) => recordAccess.AddField(rec, field.Name, field.Pos, readItem(recordAccess.GetField(rec, field.Name, field.Pos), d))); } else { fieldReaders.Add((rec, d) => recordAccess.AddField(rec, field.Name, field.Pos, readItem(null, d))); } } } } } return(recordReader); }
public async Task ReadWriteSingleWords() { await PlcTestServer.ExecuteClientAsync(async (client) => { const string datablock = "DB1"; var writeResults = (await client.WriteAsync(WriteItem.Create(datablock, 10002, (ushort)0), WriteItem.Create(datablock, 10004, (short)0))).ToArray(); var results = (await client.ReadAsync(ReadItem.Create <ushort>(datablock, 10002), ReadItem.Create <short>(datablock, 10004))).ToArray(); Assert.Equal(2, results.Count()); Assert.Equal(typeof(ushort), results[0].Type); Assert.Equal((ushort)0, (ushort)results[0].Value); Assert.Equal(typeof(short), results[1].Type); Assert.Equal((short)0, (short)results[1].Value); writeResults = (await client.WriteAsync(WriteItem.Create(datablock, 10002, (ushort)15), WriteItem.Create(datablock, 10004, (short)25))).ToArray(); results = (await client.ReadAsync(ReadItem.Create <ushort>(datablock, 10002), ReadItem.Create <short>(datablock, 10004))).ToArray(); Assert.Equal(2, results.Count()); Assert.Equal(typeof(ushort), results[0].Type); Assert.Equal((ushort)15, (ushort)results[0].Value); Assert.Equal(typeof(short), results[1].Type); Assert.Equal((short)25, (short)results[1].Value); writeResults = (await client.WriteAsync(WriteItem.Create(datablock, 10002, (ushort)0), WriteItem.Create(datablock, 10004, (short)0))).ToArray(); }); }
public async Task ReadWriteMultibleCharsStringLongerThanPDUSize() { const string datablock = "DB141"; await PlcTestServer.ExecuteClientAsync(async (client) => { var data = new List <ReadItem> { ReadItem.Create <char[]>(datablock, 28, 14), ReadItem.Create <char[]>(datablock, 46, 10), ReadItem.Create <string>(datablock, 106, 10), ReadItem.Create <char[]>(datablock, 124, 10), ReadItem.Create <char[]>(datablock, 134, 10), ReadItem.Create <char[]>(datablock, 60, 8), ReadItem.Create <char[]>(datablock, 86, 8), ReadItem.Create <char[]>(datablock, 94, 8), ReadItem.Create <char[]>(datablock, 116, 8), ReadItem.Create <char[]>(datablock, 0, 8), ReadItem.Create <char[]>(datablock, 8, 8), ReadItem.Create <char[]>(datablock, 16, 8), ReadItem.Create <char[]>(datablock, 76, 6), ReadItem.Create <char[]>(datablock, 24, 4), ReadItem.Create <char[]>(datablock, 42, 4), ReadItem.Create <char[]>(datablock, 56, 4) }; var results = (await client.ReadAsync(data)).ToArray(); Assert.Equal(data.Count, results.Length); Assert.True(results.All(x => x.IsSuccessReturnCode)); var writeResults = await client.WriteAsync(data.Select((r, i) => r.From(results[i].Data)).ToArray()); Assert.Equal(data.Count, writeResults.Count()); Assert.True(writeResults.All(x => x == ItemResponseRetValue.Success)); }, 240); }
public async Task ReadWriteSingles() { await PlcTestServer.ExecuteClientAsync(async (client) => { const string datablock = "DB1"; var writeResults = (await client.WriteAsync(WriteItem.Create(datablock, 10014, (float)0.0))).ToArray(); var results = (await client.ReadAsync(ReadItem.Create <float>(datablock, 10014))).ToArray(); Assert.Single(results); Assert.Equal(typeof(float), results[0].Type); Assert.Equal((float)0.0, (float)results[0].Value); writeResults = (await client.WriteAsync(WriteItem.Create(datablock, 10014, (float)0.5))).ToArray(); results = (await client.ReadAsync(ReadItem.Create <float>(datablock, 10014))).ToArray(); Assert.Single(results); Assert.Equal(typeof(float), results[0].Type); Assert.Equal((float)0.5, (float)results[0].Value); writeResults = (await client.WriteAsync(WriteItem.Create(datablock, 10014, (float)0.0))).ToArray(); }); }
private object ReadUnion(JsonReader jr, UnionSchema unionSchema) { ReadItem readMember = null; bool canBeNull = false; foreach (Schema.Schema memberSchema in unionSchema.Schemas) { if (memberSchema.Type == SchemaType.Null) { canBeNull = true; continue; } if (readMember == null) { readMember = ResolveItemReader(memberSchema); } } if (canBeNull && jr.TokenType == JsonToken.Null) { return(null); } if (readMember == null) { throw new BaijiException("Corresponding schema not found."); } return(readMember(jr)); }
public async Task ReadWriteString() { const string datablock = "DB962"; await PlcTestServer.ExecuteClientAsync(async (client) => { var data0 = new List <WriteItem> { WriteItem.Create <string>(datablock, 58, 14, "XXXXXXXXXXXXXX") }; var writeResults1 = await client.WriteAsync(data0); Assert.Equal(data0.Count, writeResults1.Count()); Assert.True(writeResults1.All(x => x == ItemResponseRetValue.Success)); var data1 = new List <ReadItem> { ReadItem.Create <string>(datablock, 58, 14) }; var readResults1 = await client.ReadAsync(data1); var data = new List <WriteItem> { WriteItem.Create <string>(datablock, 58, 14, "1234567890ABCD") }; var writeResults2 = await client.WriteAsync(data); Assert.Equal(data.Count, writeResults2.Count()); Assert.True(writeResults2.All(x => x == ItemResponseRetValue.Success)); var readResults2 = await client.ReadAsync(data1); Assert.False(readResults1.FirstOrDefault().Data.Span.SequenceEqual(readResults2.FirstOrDefault().Data.Span)); }, 240); }
private object ReadArray(JsonReader jr, ArraySchema arraySchema) { if (jr.TokenType == JsonToken.Null) { return(null); } if (jr.TokenType != JsonToken.StartArray) { throw new BaijiRuntimeException("An array should start with '['."); } var itemType = LoadType(arraySchema); var ctor = GetConstructor(arraySchema, itemType.ToString()); var array = (IList)ctor(); ReadItem readArrayItem = ResolveItemReader(arraySchema.ItemSchema); while (jr.Read() && jr.TokenType != JsonToken.EndArray) { if (jr.TokenType == JsonToken.Null) { continue; } var arrayItem = readArrayItem(jr); array.Add(arrayItem); } return(array); }
private object ReadMap(JsonReader jr, MapSchema mapSchema) { if (jr.TokenType == JsonToken.Null) { return(null); } if (jr.TokenType != JsonToken.StartObject) { throw new BaijiRuntimeException("A map should start with '{'."); } var valueType = LoadType(mapSchema.ValueSchema); var ctor = GetConstructor(mapSchema, valueType.ToString()); var dictionary = (IDictionary)ctor(); ReadItem readValueItem = ResolveItemReader(mapSchema.ValueSchema); while (jr.Read() && jr.TokenType != JsonToken.EndObject) { string key = jr.Value.ToString(); jr.Read(); var valueItem = readValueItem(jr); dictionary.Add(key, valueItem); } return(dictionary); }
public async Task <ApiResponse <object> > Add([FromForm] ReadItem readItem) { var response = new ApiResponse <object>(); try { readItem.IsCompleted = Request.Form["isCompleted"] == "on"; readItem.IsPublished = Request.Form["isPublished"] == "on"; var readRequest = new ReadGrpcRequest { ReadItem = readItem }; var readResponse = await _readGrpcService.AddReadItemAsync(readRequest); if (readResponse.IsOk) { response.RedirectTo = "/read"; } else { response.IsOk = false; response.Message = readResponse.Message; } } catch (Exception ex) { response.IsOk = false; response.Message = ex.Message; _logger.LogError(ex, $"Add new read failed. {JsonUtil.Serialize(readItem)}"); } return(response); }
private DataValue CreateTestValue <T>(T value) { ushort countItems = 1; if (value is IList l) { countItems = (ushort)l.Count; } else if (value is string s) { countItems = (ushort)s.Length; } var ri = ReadItem.Create <T>("DB1", 0, countItems); var itemData = ri.ConvertDataToMemory(value); Memory <byte> buffer = new byte[4 + itemData.Length]; buffer.Span[0] = 255; buffer.Span[1] = 3; BinaryPrimitives.WriteUInt16BigEndian(buffer.Span.Slice(2, 2), (ushort)itemData.Length); itemData.CopyTo(buffer.Slice(4)); return(new DataValue(ri, S7DataItemSpecification.TranslateFromMemory(buffer))); }
void HandleReadItem(ReadItem readItem) { Item item = _player.GetItemByPos(readItem.PackSlot, readItem.Slot); if (item != null && item.GetTemplate().GetPageText() != 0) { InventoryResult msg = _player.CanUseItem(item); if (msg == InventoryResult.Ok) { ReadItemResultOK packet = new(); packet.Item = item.GetGUID(); SendPacket(packet); } else { // @todo: 6.x research new values /*WorldPackets.Item.ReadItemResultFailed packet; * packet.Item = item.GetGUID(); * packet.Subcode = ??; * packet.Delay = ??; * SendPacket(packet);*/ Log.outInfo(LogFilter.Network, "STORAGE: Unable to read item"); _player.SendEquipError(msg, item); } } else { _player.SendEquipError(InventoryResult.ItemNotFound); } }
public async Task <IHttpActionResult> PutReadItem(int id, ReadItem readItem) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != readItem.Id) { return(BadRequest()); } db.Entry(readItem).State = EntityState.Modified; try { await db.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!ReadItemExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
private object ReadRecord(JsonReader jr, RecordSchema recordSchema) { if (jr.TokenType == JsonToken.Null) { return(null); } if (jr.TokenType != JsonToken.StartObject) { throw new BaijiRuntimeException("An object should start with '{'."); } var ctor = GetConstructor(recordSchema, recordSchema.Fullname); var recordObject = ctor(); while (jr.Read() && jr.TokenType != JsonToken.EndObject) { string fieldName = jr.Value.ToString(); Field field; recordSchema.TryGetField(fieldName.ToLower(), out field); if (field == null) { ReadDummyData(jr); continue; } ReadItem readField = ResolveItemReader(field.Schema); jr.Read(); var fieldValue = readField(jr); Put(recordObject, field.Pos, fieldValue); } return(recordObject); }
public async Task ReadWriteMultibleDInts() { await PlcTestServer.ExecuteClientAsync(async (client) => { const string datablock = "DB1"; var writeDataDefault = new int[] { 0, 0 }; const int startAddress = 10038; var writeResults = (await client.WriteAsync(WriteItem.Create(datablock, startAddress, writeDataDefault))).ToArray(); var results = (await client.ReadAsync(ReadItem.Create <int>(datablock, startAddress, 2))).ToArray(); Assert.Single(results); Assert.Equal(typeof(int[]), results[0].Type); var resultValueDefault = results[0].GetValue <int[]>(); Assert.True(resultValueDefault.SequenceEqual(writeDataDefault)); var writeData = new int[] { 22, 21 }; writeResults = (await client.WriteAsync(WriteItem.Create(datablock, startAddress, writeData))).ToArray(); results = (await client.ReadAsync(ReadItem.Create <int>(datablock, startAddress, 2))).ToArray(); Assert.Single(results); Assert.Equal(typeof(int[]), results[0].Type); var resultValue = results[0].GetValue <int[]>(); Assert.True(resultValue.SequenceEqual(writeData)); writeResults = (await client.WriteAsync(WriteItem.Create(datablock, startAddress, writeDataDefault))).ToArray(); }); }
public async Task ReadWriteSingles() { await PlcTestServer.ExecuteClientAsync(async (client) => { var originWriteTags = new Dictionary <string, object> { { $"DB2.10014,r", (float)0.0 } }; var writeResults = (await client.WriteAsync(originWriteTags.Select(w => WriteItem.CreateFromTag(w.Key, w.Value)))).ToArray(); var results = (await client.ReadAsync(originWriteTags.Select(w => ReadItem.CreateFromTag(w.Key)))).ToArray(); Assert.Single(results); Assert.Equal(typeof(float), results[0].Type); Assert.Equal((float)0.0, (float)results[0].Value); var writeTags = new Dictionary <string, object> { { $"DB2.10014,r", (float)0.5 } }; writeResults = (await client.WriteAsync(writeTags.Select(w => WriteItem.CreateFromTag(w.Key, w.Value)))).ToArray(); results = (await client.ReadAsync(writeTags.Select(w => ReadItem.CreateFromTag(w.Key)))).ToArray(); Assert.Single(results); Assert.Equal(typeof(float), results[0].Type); Assert.Equal((float)0.5, (float)results[0].Value); writeResults = (await client.WriteAsync(originWriteTags.Select(w => WriteItem.CreateFromTag(w.Key, w.Value)))).ToArray(); }); }
bool RegisterItem(ReadItem readItem) // only called while initializing { while (itemHash.ContainsKey(registeredID) && registeredID < maxRegisterNumber) { registeredID++; } if (registeredID == maxRegisterNumber) { return(false); } else { string itemName = readItem.Name; GameObject itemPrefab = Resources.Load <GameObject>(readItem.PrefabPath); Sprite itemImage = Resources.Load <Sprite>(readItem.ImagePath); int usageOrder = readItem.UsageOrder; int usagePara = readItem.UsagePara; Item newItem = new Item(this, registeredID, itemName, itemPrefab, itemImage, usageOrder, usagePara); itemHash.Add(registeredID, newItem); return(true); } }
public async Task ReadWriteBigDBData() { await PlcTestServer.ExecuteClientAsync(async (client) => { var data = Enumerable.Repeat((byte)0x00, 1000).ToArray(); var originWriteTags = new Dictionary <string, object> { { $"DB2.2500,b,1000", data } }; var writeResults = (await client.WriteAsync(originWriteTags.Select(w => WriteItem.CreateFromTag(w.Key, w.Value)))).ToArray(); var results = (await client.ReadAsync(originWriteTags.Select(w => ReadItem.CreateFromTag(w.Key)))).ToArray(); Assert.True(results.FirstOrDefault().Data.ToArray().SequenceEqual(data)); var data2 = Enumerable.Repeat((byte)0x25, 1000).ToArray(); var writeTags = new Dictionary <string, object> { { $"DB2.2500,b,1000", data2 } }; writeResults = (await client.WriteAsync(writeTags.Select(w => WriteItem.CreateFromTag(w.Key, w.Value)))).ToArray(); results = (await client.ReadAsync(writeTags.Select(w => ReadItem.CreateFromTag(w.Key)))).ToArray(); Assert.True(results.FirstOrDefault().Data.ToArray().SequenceEqual(data2)); writeResults = (await client.WriteAsync(originWriteTags.Select(w => WriteItem.CreateFromTag(w.Key, w.Value)))).ToArray(); }); }
public async Task ReadWriteSingleStrings() { await PlcTestServer.ExecuteClientAsync(async (client) => { const string datablock = "DB1"; var writeResults = (await client.WriteAsync(WriteItem.Create(datablock, 10046, ""), WriteItem.Create(datablock, 10068, " "))).ToArray(); var results = (await client.ReadAsync(ReadItem.Create <string>(datablock, 10046, 20), ReadItem.Create <string>(datablock, 10068, 20))).ToArray(); Assert.Equal(2, results.Count()); Assert.Equal(typeof(string), results[0].Type); Assert.Equal("", (string)results[0].Value); Assert.Equal(typeof(string), results[1].Type); Assert.Equal(" ", (string)results[1].Value); writeResults = (await client.WriteAsync(WriteItem.Create(datablock, 10046, "Test1"), WriteItem.Create(datablock, 10068, "Test2 "))).ToArray(); results = (await client.ReadAsync(ReadItem.Create <string>(datablock, 10046, 20), ReadItem.Create <string>(datablock, 10068, 20))).ToArray(); Assert.Equal(2, results.Count()); Assert.Equal(typeof(string), results[0].Type); Assert.Equal("Test1", (string)results[0].Value); Assert.Equal(typeof(string), results[1].Type); Assert.Equal("Test2 ", (string)results[1].Value); writeResults = (await client.WriteAsync(WriteItem.Create(datablock, 10046, ""), WriteItem.Create(datablock, 10068, " "))).ToArray(); }); }
public void AddElements(object arrayObj, int elements, int index, ReadItem itemReader, Decoder decoder, bool reuse) { var array = (object[])arrayObj; for (int i = index; i < index + elements; i++) { array[i] = reuse ? itemReader(array[i], decoder) : itemReader(null, decoder); } }
public async Task ReadWriteDataAndCheckIfTheResultsDontChangeBecauseOfBufferReusing() { await PlcTestServer.ExecuteClientAsync(async (client) => { const string datablock = "DB4"; const ushort offset = 2500; var resultsDefault0 = new Memory <byte>(Enumerable.Repeat((byte)0x00, 1000).ToArray()); var resultsDefault1 = await client.WriteAsync(WriteItem.Create(datablock, offset, resultsDefault0)); var resultsDefault2 = (await client.ReadAsync(ReadItem.Create <byte[]>(datablock, offset, 1000))); var first = resultsDefault2.FirstOrDefault(); var copy1 = new byte[first.Data.Length]; first.Data.CopyTo(copy1); Assert.True(resultsDefault0.Span.SequenceEqual(first.Data.Span), "1"); Assert.True(resultsDefault0.Span.SequenceEqual(copy1), "2"); var results0 = new Memory <byte>(Enumerable.Repeat((byte)0x25, 1000).ToArray()); var results1 = await client.WriteAsync(WriteItem.Create(datablock, offset, results0)); var results2 = (await client.ReadAsync(ReadItem.Create <byte[]>(datablock, offset, 1000))); var second = results2.FirstOrDefault(); var copy2 = new byte[second.Data.Length]; second.Data.CopyTo(copy2); resultsDefault1 = await client.WriteAsync(WriteItem.Create(datablock, offset, resultsDefault0)); Assert.True(results0.Span.SequenceEqual(results2.FirstOrDefault().Data.Span), "3"); Assert.True(results0.Span.SequenceEqual(copy2), "4"); var results00 = new Memory <byte>(Enumerable.Repeat((byte)0x01, 1000).ToArray()); var results01 = await client.WriteAsync(WriteItem.Create(datablock, offset, results00)); var results02 = (await client.ReadAsync(ReadItem.Create <byte[]>(datablock, offset, 1000))); var third = results02.FirstOrDefault(); var copy3 = new byte[third.Data.Length]; third.Data.CopyTo(copy3); resultsDefault1 = await client.WriteAsync(WriteItem.Create(datablock, offset, resultsDefault0)); Assert.True(results00.Span.SequenceEqual(results02.FirstOrDefault().Data.Span), "5"); Assert.True(results00.Span.SequenceEqual(copy3), "6"); Assert.True(resultsDefault0.Span.SequenceEqual(first.Data.Span), "7"); Assert.True(resultsDefault0.Span.SequenceEqual(copy1), "8"); Assert.True(first.Data.Span.SequenceEqual(copy1), "9"); Assert.True(results0.Span.SequenceEqual(second.Data.Span), "10"); Assert.True(results0.Span.SequenceEqual(copy2), "11"); Assert.True(second.Data.Span.SequenceEqual(copy2), "12"); Assert.True(results00.Span.SequenceEqual(third.Data.Span), "13"); Assert.True(results00.Span.SequenceEqual(copy3), "14"); Assert.True(third.Data.Span.SequenceEqual(copy3), "15"); }); }
public void AddElements(object array, int elements, int index, ReadItem itemReader, Decoder decoder, bool reuse) { var list = (IList)array; for (int i = 0; i < elements; i++) { list.Add(itemReader(null, decoder)); } }
public void AddElements(object mapObj, int elements, ReadItem itemReader, IDecoder decoder, bool reuse) { var map = ((IDictionary <string, object>)mapObj); for (int i = 0; i < elements; i++) { var key = decoder.ReadString(); map[key] = itemReader(null, decoder); } }
public void TestReadItemInvalidNumberOfBitsThrowsException() { Assert.Throws <Dacs7TypeNotSupportedException>(() => ReadItem.CreateFromTag("DB3.10000,x0,2")); Assert.Throws <Dacs7TypeNotSupportedException>(() => ReadItem.Create <bool[]>("DB1", 0, 2)); Assert.Throws <Dacs7TypeNotSupportedException>(() => ReadItem.Create <bool>("DB1", 0, 2)); Assert.Throws <Dacs7TypeNotSupportedException>(() => ReadItem.Create <bool[]>("DB1", 0)); Assert.Throws <Dacs7TypeNotSupportedException>(() => ReadItem.Create <bool>("DB1", 0, 2)); }
private object ReadMap(object reuse, Decoder decoder, MapAccess mapAccess, ReadItem valueReader) { object map = mapAccess.Create(reuse); for (int n = (int)decoder.ReadMapStart(); n != 0; n = (int)decoder.ReadMapNext()) { mapAccess.AddElements(map, n, valueReader, decoder, false); } return(map); }
protected PreresolvingDatumReader(Schema writerSchema, Schema readerSchema) { ReaderSchema = readerSchema; WriterSchema = writerSchema; if (!ReaderSchema.CanRead(WriterSchema)) { throw new AvroException("Schema mismatch. Reader: " + ReaderSchema + ", writer: " + WriterSchema); } _reader = ResolveReader(writerSchema, readerSchema); }
private static uint[] ConvertMemoryToUInt32(ReadItem item, Memory <byte> data) { var result = new uint[item.NumberOfItems]; for (var i = 0; i < item.NumberOfItems; i++) { result[i] = BinaryPrimitives.ReadUInt32BigEndian(data.Slice(i * 4).Span); } return(result); }
private static short[] ConvertMemoryToInt16(ReadItem item, Memory <byte> data) { var result = new short[item.NumberOfItems]; for (var i = 0; i < item.NumberOfItems; i++) { result[i] = BinaryPrimitives.ReadInt16BigEndian(data.Slice(i * 2).Span); } return(result); }
private ReadItem ResolveUnion(UnionSchema schema) { var lookup = new ReadItem[schema.Count]; for (int i = 0; i < schema.Count; i++) { lookup[i] = ResolveReader(schema[i]); } return((r, d) => ReadUnion(r, d, lookup)); }