public void WriteThing(SomeMemoryStreamWrapperThing dest, object subject) { var type = TypeSimplifier.SimplifyType((Type)subject); var typeBinaryRepresentation = fullTypeBinaryRepresentationCache.GetOrCompute(type); dest.Write(fullTypeBinaryRepresentationCache.GetOrCompute(typeof(Type))); dest.Write(typeBinaryRepresentation); }
private void HandleWriteThingUInt8(SomeMemoryStreamWrapperThing dest, byte subject) { dest.Write(fullTypeBinaryRepresentationCache.GetOrCompute(typeof(byte))); var buffer = GetWriterBuffer(); buffer[0] = subject; dest.Write(buffer, 0, sizeof(byte)); }
public void WriteThing(SomeMemoryStreamWrapperThing dest, object subject) { dest.Write(fullTypeBinaryRepresentationCache.GetOrCompute(typeof(string))); var str = (string)subject; using (dest.ReserveLength()) { var bytes = Encoding.UTF8.GetBytes(str); dest.Write(bytes); } }
public void WriteThing(SomeMemoryStreamWrapperThing dest, object subject) { dest.Write(fullTypeBinaryRepresentationCache.GetOrCompute(typeof(float))); var buffer = GetWriterBuffer(); fixed(byte *pBuffer = buffer) { *(float *)pBuffer = (float)subject; } dest.Write(buffer); }
private void HandleWriteThingUInt64(SomeMemoryStreamWrapperThing dest, ulong subject) { if (subject > uint.MaxValue) { dest.Write(fullTypeBinaryRepresentationCache.GetOrCompute(typeof(ulong))); var buffer = GetWriterBuffer(); fixed(byte *pBuffer = buffer) { *(ulong *)pBuffer = subject; } dest.Write(buffer, 0, sizeof(ulong)); } else { HandleWriteThingUInt32(dest, (uint)subject); } }
private void HandleWriteThingUInt16(SomeMemoryStreamWrapperThing dest, ushort subject) { if (subject > byte.MaxValue) { dest.Write(fullTypeBinaryRepresentationCache.GetOrCompute(typeof(ushort))); var buffer = GetWriterBuffer(); fixed(byte *pBuffer = buffer) { *(ushort *)pBuffer = subject; } dest.Write(buffer, 0, sizeof(ushort)); } else { HandleWriteThingUInt8(dest, (byte)subject); } }
private void HandleWriteThingInt32(SomeMemoryStreamWrapperThing dest, int subject) { if (subject < short.MinValue || subject > short.MaxValue) { dest.Write(fullTypeBinaryRepresentationCache.GetOrCompute(typeof(int))); var buffer = GetWriterBuffer(); fixed(byte *pBuffer = buffer) { *(int *)pBuffer = subject; } dest.Write(buffer, 0, sizeof(int)); } else { HandleWriteThingInt16(dest, (short)subject); } }
public void WriteThing(SomeMemoryStreamWrapperThing dest, object subject) { dest.Write(fullTypeBinaryRepresentationCache.GetOrCompute(simplifiedKvpType)); using (dest.ReserveLength()) { dynamic s = subject; thisIsTotesTheRealLegitThingReaderWriterThing.WriteThing(dest, s.Key); thisIsTotesTheRealLegitThingReaderWriterThing.WriteThing(dest, s.Value); } }
public void WriteThing(SomeMemoryStreamWrapperThing dest, object subject) { dest.Write(fullTypeBinaryRepresentationCache.GetOrCompute(simplifiedType)); using (dest.ReserveLength()) using (var slotCountReservation = dest.ReserveCount()) { var writer = new WriterThing(thisIsTotesTheRealLegitThingReaderWriterThing, dest); userTypeSerializer.Serialize(writer, (TUserType)subject); slotCountReservation.SetValue(writer.SlotCount); } }
public void WriteThing(SomeMemoryStreamWrapperThing dest, object subject) { var byteArraySlice = (ByteArraySlice)subject; dest.Write(fullTypeBinaryRepresentationCache.GetOrCompute(typeof(byte[]))); using (dest.ReserveLength()) using (var countReservation = dest.ReserveCount()) { for (var i = 0; i < byteArraySlice.Length; i++) { byteReaderWriter.WriteThing(dest, byteArraySlice.Buffer[i + byteArraySlice.Offset]); } countReservation.SetValue(byteArraySlice.Length); } }
public void WriteThing(SomeMemoryStreamWrapperThing dest, object subject) { dest.Write(fullTypeBinaryRepresentationCache.GetOrCompute(simplifiedCollectionType)); using (dest.ReserveLength()) using (var countReservation = dest.ReserveCount()) { int count = 0; foreach (var x in (IEnumerable)subject) { count++; thingReaderWriterDispatcherThing.WriteThing(dest, x); } countReservation.SetValue(count); } }
public void WriteThing(SomeMemoryStreamWrapperThing dest, object subject) { dest.Write(fullTypeBinaryRepresentationCache.GetOrCompute(typeof(TBoolTrue))); }
public void WriteThing(SomeMemoryStreamWrapperThing dest, object subject) { dest.Write(fullTypeBinaryRepresentationCache.GetOrCompute(typeof(Guid))); dest.Write(((Guid)subject).ToByteArray()); }