示例#1
0
        public void TestImmutable()
        {
            var settings = new SerializerSettings();

            settings.RegisterTagMapping("MyClassImmutable", typeof(MyClassImmutable));

            // Automatically register MyClassImmutableSerializer assembly
            settings.RegisterAssembly(typeof(SerializationTests2).Assembly);

            var immutable  = new MyClassImmutable("Test", 1);
            var serializer = new Serializer(settings);
            var text       = serializer.Serialize(immutable);

            var newImmutable = serializer.Deserialize(text);

            Assert.AreEqual(immutable, newImmutable);
        }
示例#2
0
 public MyClassMutable(MyClassImmutable immutable)
 {
     Name  = immutable.Name;
     Value = immutable.Value;
 }
示例#3
0
 protected bool Equals(MyClassImmutable other)
 {
     return(string.Equals(Name, other.Name) && Value == other.Value);
 }