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); }
public MyClassMutable(MyClassImmutable immutable) { Name = immutable.Name; Value = immutable.Value; }
protected bool Equals(MyClassImmutable other) { return(string.Equals(Name, other.Name) && Value == other.Value); }