public void Serialize(IBinarySerializer serializer) { serializer.Write((int)Action); serializer.Write(Key); serializer.Write(Data); serializer.Write(Source); }
public void Serialize(IBinarySerializer serializer) { serializer.Write(A); serializer.Write(B); serializer.Write(Version); serializer.Write(Connected ? 1 : 0); }
public static void WriteList <T>(this IBinarySerializer serializer, ICollection <T> list) where T : IBinarySerializable { serializer.Write(list.Count); foreach (var item in list) { serializer.Write(item); } }
public static void WriteList <T>(this IBinarySerializer serializer, ICollection <T> list, Action <IBinarySerializer, T> serializeFunc) { serializer.Write(list.Count); foreach (var item in list) { serializeFunc(serializer, item); } }
public static void SerializeCollection <TValue>(this IBinarySerializer binarySerializer, ICollection <TValue> collection, Action <TValue> onItemSerialize) { binarySerializer.Write(collection.Count); foreach (var value in collection) { onItemSerialize(value); } }
public void Test_Writing_An_Object() { string value = "value"; IReadOnlyList <uint> offsets = new List <uint> { 1, 2, 3 }; treeWriter(binaryWriter, value, rootNode).Returns(offsets); serializer.Write(binaryWriter, value); Received.InOrder(() => { treeWriter(binaryWriter, value, rootNode); footerAligner(binaryWriter); offsets.ForEach(binaryWriter.WriteUInt32); binaryWriter.WriteInt32(offsets.Count); binaryWriter.WriteUInt32(TreeBinarySerializer <object> .FOOTER_MAGIC_NUMBER); }); }
public void Test_Writing_With_A_BinarySerializer_Directly_To_A_Stream() { string value = nameof(value); WithDummyStream(stream => { binarySerializer.Write(stream, value); binarySerializer.Received().Write(Arg.Do <IBinaryWriter>(binaryReader => { binaryReader.Should().BeOfType <BinaryWriterWrapper>(); typeof(BinaryWriterWrapper) .GetField("realReader", BindingFlags.Instance | BindingFlags.NonPublic) .GetValue(binaryReader) .Should() .BeSameAs(stream); }), value); }); }
public void Serialize(IBinarySerializer binarySerializer, Action <TKey> keySerializer, Action <TValue> valueSerializer) { var indexCopy = _index.ToArray(); binarySerializer.Write(indexCopy.Length); foreach (var value in indexCopy) { keySerializer(value.Key); valueSerializer(value.Value); } }
public void Test_Writing_With_A_Null_BinarySerializer_Directly_To_A_Stream() { IBinarySerializer <string> binarySerializer = null; WithDummyStream(stream => { Action action = () => binarySerializer.Write(stream, string.Empty); action.Should() .ThrowArgumentNullException("binarySerializer"); }); }
public void Test_Writing_BKD_File_Successfully(SerializationTestCaseData <BKD> testCaseData) { byte[] expected = File.ReadAllBytes(testCaseData.TestFilePath); using (var stream = new MemoryStream()) { var writer = Writer.ForStream(stream); serializer.Write(writer, testCaseData.Expected); stream.ToArray() .Should() .Equal(expected); } }
public override void Serialize(IBinarySerializer serializer) { serializer.Write(ExecutorId); serializer.Write(ApiKey); }
public void Serialize(IBinarySerializer serializer) { serializer.Write(ExecutorId); serializer.Write(ExecutorApiKey); }
public void Serialize(IBinarySerializer serializer) { serializer.Write(Endpoint.Address.GetAddressBytes()); serializer.Write(Endpoint.Port); }
public void Serialize(IBinarySerializer serializer) { serializer.Write(Limit); }
public void Serialize(IBinarySerializer serializer) { serializer.WriteList(Links); serializer.Write(SuggestDisconnect ? 1 : 0); }
public void Serialize(IBinarySerializer serializer) { serializer.Write(Destination); serializer.Write(Data); }
public override void Serialize(IBinarySerializer serializer) { serializer.Write(CommandName); serializer.Write(ApiKey); }
public void Serialize(IBinarySerializer serializer) { serializer.Write(Name); serializer.SerializeCollection(Admins, serializer.Write); }