public void TestExternalReferences()
        {
            var           serializer = CreateSerializer();
            ReferenceTest test       = new ReferenceTest();

            test.someStr    = "i am object #1";
            test.identifier = "test";
            ReferenceTest test2 = new ReferenceTest();

            test2.someStr    = "i am object #2";
            test2.identifier = "test2";
            test2.someRef    = test;

            List <ISerializableRoot> roots = new List <ISerializableRoot>(), externalRefs = new List <ISerializableRoot>();

            roots.Add(test2);
            string xml = serializer.Serialize(roots, out errors);

            FlushErrors();
            Debug.Log(xml);

            externalRefs.Add(test);
            roots.Clear();
            serializer.Deserialize(new string[] { xml }, new string[] { "MEMORY" }, externalRefs, out roots, out errors);
            FlushErrors();

            Assert.AreEqual(roots.Count, 1);
            Assert.AreEqual(test2.identifier, roots[0].identifier);
            Assert.AreEqual(test2, roots[0]);
            Assert.IsTrue(ReferenceEquals(test2.someRef, test));
        }
Exemple #2
0
    public static void Run()
    {
        ReferenceTest test = new ReferenceTest();

        ReferneceTest3 test3 = new ReferneceTest3();

        test3.list = test.list;

        test3.list[2] = 999;

        test.Print();
    }
Exemple #3
0
        public static void Test()
        {
            var tmp = new ReferenceTest {
                IntType = 100, StringType = "new", BoolType = false
            };
            var tmp1 = new ReferenceTest {
                IntType = 101, StringType = "new1", BoolType = false
            };

            ChangeClassContent(tmp); // 改变
            ChangedClass(tmp1);      // 不变
        }
Exemple #4
0
    public static void Run()
    {
        ReferenceTest referenceTest = new ReferenceTest();

        referenceTest.Test1();
    }
Exemple #5
0
 /// <summary>
 /// 改变内容
 /// </summary>
 /// <param name="rft"></param>
 public static void ChangeClassContent(ReferenceTest rft)
 {
     rft.StringType = "changed";
     rft.IntType    = 404;
     rft.BoolType   = true;
 }
Exemple #6
0
 /// <summary>
 /// 重新赋值
 /// </summary>
 /// <param name="rft"></param>
 public static void ChangedClass(ReferenceTest rft)
 {
     rft         = new ReferenceTest();
     rft.IntType = 405;
 }