public bool IsSame(ReferencedClass other)
 {
     return
         ((MyCascadedClass == null
             ? other.MyCascadedClass == null
             : MyCascadedClass.IsSame(other.MyCascadedClass)) &&
          (MyPropertyClass == null
             ? other.MyPropertyClass == null
             : MyPropertyClass.IsSame(other.MyPropertyClass)));
 }
        public void CloneClass()
        {
            var value = new ReferencedClass
            {
                MyPropertyClass =
                {
                    MyStringProperty = "Hello World!",
                    MyGuid           = new Guid("{fb82b37c-cc56-415e-baea-773f4bbe7203}")
                },
            };
            var w  = new Writer();
            var cs = new ClassSerializer(typeof(ReferencedClass));

            Assert.True(cs.Write(w, value, null));

            var r      = new Reader(w.ToString(), ReadOptions.RecreateGuids);
            var result = cs.Read(r, null, null) as ReferencedClass;

            Assert.IsNotNull(result);
            Assert.AreNotEqual(value.MyPropertyClass.MyGuid, result.MyPropertyClass.MyGuid);
            Assert.AreNotEqual((value.MyCascadedClass.MyPropertyClass as PropertyClassGuid)?.MyGuid, (result.MyCascadedClass.MyPropertyClass as PropertyClassGuid)?.MyGuid);
        }
        public void ReferencedClass()
        {
            var value = new ReferencedClass
            {
                MyPropertyClass =
                {
                    MyStringProperty = "Hello World!",
                    MyGuid           = new Guid("{fb82b37c-cc56-415e-baea-773f4bbe7203}")
                },
            };
            var w  = new Writer();
            var cs = new ClassSerializer(typeof(ReferencedClass));

            Assert.True(cs.Write(w, value, null));
            Assert.AreEqual("!Test.ReferencedClass{MyPropertyClass:!Test.PropertyClassGuid{MyGuid:fb82b37ccc56415ebaea773f4bbe7203,MyStringProperty:\"Hello World!\"},MyCascadedClass:!Test.CascadedClass{MyEmptyClass:!Test.EmptyClass{},MyPropertyClass:?fb82b37ccc56415ebaea773f4bbe7203}}", w.ToString());

            var r      = new Reader(w.ToString());
            var result = cs.Read(r, null, null) as ReferencedClass;

            Assert.IsNotNull(result);
            Assert.IsFalse(r.AnyLeft, "Any characters left.");
            Assert.IsTrue(value.IsSame(result), "Read back value is not the same.");
        }