public void TestWriteDataWithPortable()
        {
            var ss = new SerializationServiceBuilder()
                     .AddPortableFactory(TestSerializationConstants.PORTABLE_FACTORY_ID,
                                         new PortableFactoryFunc(i => new NamedPortableV2()))
                     .AddDataSerializableFactory(TestSerializationConstants.DATA_SERIALIZABLE_FACTORY_ID,
                                                 GetDataSerializableFactory())
                     .Build();

            var ss2 = new SerializationServiceBuilder()
                      .AddPortableFactory(TestSerializationConstants.PORTABLE_FACTORY_ID,
                                          new PortableFactoryFunc(i => new NamedPortable()))
                      .AddDataSerializableFactory(TestSerializationConstants.DATA_SERIALIZABLE_FACTORY_ID,
                                                  GetDataSerializableFactory())
                      .SetPortableVersion(5)
                      .Build();

            IPortable p1 = new NamedPortableV2("test", 456);
            object    o1 = new DataDataSerializable(ss.ToData(p1));

            var data = ss.ToData(o1);

            var o2 = ss2.ToObject <DataDataSerializable>(data);

            Assert.AreEqual(o1, o2);

            var p2 = ss2.ToObject <IPortable>(o2.Data);

            Assert.AreEqual(p1, p2);
        }
Esempio n. 2
0
 protected bool Equals(DataDataSerializable other)
 {
     return(Equals(Data, other.Data));
 }
        public void TestWriteDataWithPortable()
        {
            var ss = new SerializationServiceBuilder()
                .AddPortableFactory(TestSerializationConstants.PORTABLE_FACTORY_ID,
                    new PortableFactoryFunc(i => new NamedPortableV2()))
                .AddDataSerializableFactory(TestSerializationConstants.DATA_SERIALIZABLE_FACTORY_ID,
                    GetDataSerializableFactory())
                .Build();

            var ss2 = new SerializationServiceBuilder()
                .AddPortableFactory(TestSerializationConstants.PORTABLE_FACTORY_ID,
                    new PortableFactoryFunc(i => new NamedPortable()))
                .AddDataSerializableFactory(TestSerializationConstants.DATA_SERIALIZABLE_FACTORY_ID,
                    GetDataSerializableFactory())
                .SetPortableVersion(5)
                .Build();

            IPortable p1 = new NamedPortableV2("test", 456);
            object o1 = new DataDataSerializable(ss.ToData(p1));

            var data = ss.ToData(o1);

            var o2 = ss2.ToObject<DataDataSerializable>(data);
            Assert.AreEqual(o1, o2);

            var p2 = ss2.ToObject<IPortable>(o2.Data);
            Assert.AreEqual(p1, p2);
        }
 protected bool Equals(DataDataSerializable other)
 {
     return Equals(Data, other.Data);
 }