コード例 #1
0
ファイル: Program.cs プロジェクト: tazik047/mapping.net
 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();
             }
         }
     }
 }
コード例 #2
0
ファイル: Program2.cs プロジェクト: tazik047/mapping.net
        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);
            }

        }
コード例 #3
0
		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);
		}