コード例 #1
0
ファイル: NonGeneric.cs プロジェクト: XewTurquish/vsminecraft
 public void TestManualCloneViaSerializeDeserialize()
 {
     NonGenericBasic ngb = new NonGenericBasic { Value = 123 }, clone;
     using (MemoryStream ms = new MemoryStream())
     {
         Serializer.NonGeneric.Serialize(ms, ngb);
         ms.Position = 0;
         clone = (NonGenericBasic)Serializer.NonGeneric.Deserialize(
             ngb.GetType(), ms);
     }
     Assert.AreNotSame(ngb, clone);
     Assert.AreEqual(ngb.Value, clone.Value);
 }
コード例 #2
0
ファイル: NonGeneric.cs プロジェクト: zjatlas/protobuf-net
        public void TestManualCloneViaSerializeDeserialize()
        {
            NonGenericBasic ngb = new NonGenericBasic {
                Value = 123
            }, clone;

            using (MemoryStream ms = new MemoryStream())
            {
                Serializer.NonGeneric.Serialize(ms, ngb);
                ms.Position = 0;
                clone       = (NonGenericBasic)Serializer.NonGeneric.Deserialize(
                    ngb.GetType(), ms);
            }
            Assert.AreNotSame(ngb, clone);
            Assert.AreEqual(ngb.Value, clone.Value);
        }
コード例 #3
0
        public void TestManualCloneViaSerializeDeserialize()
        {
            NonGenericBasic ngb = new NonGenericBasic {
                Value = 123
            }, clone;

            using (MemoryStream ms = new MemoryStream())
            {
#pragma warning disable CS0618
                Serializer.NonGeneric.Serialize(ms, ngb);
                ms.Position = 0;
                clone       = (NonGenericBasic)Serializer.NonGeneric.Deserialize(
                    ngb.GetType(), ms);
#pragma warning restore CS0618
            }
            Assert.NotSame(ngb, clone);
            Assert.Equal(ngb.Value, clone.Value);
        }