private static void RunSender() { using (var f = MemoryMappedFile.CreateOrOpen("MyMapper", 100, MemoryMappedFileAccess.ReadWrite)) { using (var accessor = f.CreateViewAccessor()) { var text = "Hello World"; var t = new MyClass { Enum = MyEnum.Val1, TripId = "asdadflgh;kflhjkhhhhhhsdfsdfffffffffffffffffffffffffffffffffsd" }; using (var stream = new MemoryStream()) { var bf = new BinaryFormatter(); bf.Serialize(stream, t); var arr = stream.ToArray(); accessor.Write(1, arr.Length); accessor.WriteArray(2, arr, 0, arr.Length); accessor.Flush(); Console.WriteLine("Wait"); Console.ReadLine(); } } } }
public async Task BeginTransmit(string text) { var t = new MyClass { Enum = MyEnum.Val1, TripId = text }; using (var stream = new MemoryStream()) { var bf = new BinaryFormatter(); bf.Serialize(stream, t); var arr = stream.ToArray(); var length = BitConverter.GetBytes(arr.Length); await pipe.WriteAsync(length, 0, 4); await pipe.WriteAsync(arr, 0, arr.Length); } }
public void MapFieldTest() { var entity = new MyClass { ID = 1, Name = "Test", MyInnerClass = new MyInnerClass { Something = "Something" } }; var mapper = Map.GetObjectMapper<MyClass,MyClass>(true, true); var clone = mapper(entity); Assert.That(clone.MyInnerClass, Is.Not.Null); }