public void TestSerializeBackReference()
        {
            ChainObject head = new ChainObject(null);
            ChainObject body = new ChainObject(head);
            ChainObject tail = new ChainObject(body);

            head.Append(body);
            body.Append(tail);

            string      xml   = xstream.ToXml(head);
            ChainObject chain = xstream.FromXml(xml) as ChainObject;
            ChainObject next  = chain.Next;

            Assert.IsNotNull(chain);
            Assert.AreEqual(head.Title, chain.Title);
            Assert.IsNull(chain.BackRef);
            Assert.IsNotNull(next);
            Assert.AreEqual(body.Title, next.Title);
            Assert.IsNotNull(next.BackRef);
            Assert.AreEqual(head.Title, next.BackRef.Title);
            Assert.IsNotNull(next.Next);

            chain = next.Next;
            Assert.AreEqual(tail.Title, chain.Title);
            Assert.IsNotNull(chain.BackRef);
            Assert.AreEqual(body.Title, chain.BackRef.Title);
            Assert.IsNull(chain.Next);
        }
Exemplo n.º 2
0
        private void RegisterChainData(XmlNode configNode)
        {
            lock (this.pipesChains)
            {
                LinkedList <ChainObject> objects = new LinkedList <ChainObject>();
                String chainName = configNode.Attributes["name"].Value;

                foreach (XmlNode xmlNd in configNode)
                {
                    if (xmlNd.Name.ToLower().Equals("pipename"))
                    {
                        objects.AddLast(new ChainObject(ChainObjectType.Pipe, xmlNd.InnerText));
                    }
                    else if (xmlNd.Name.ToLower().Equals("chainname"))
                    {
                        objects.AddLast(new ChainObject(ChainObjectType.Chain, xmlNd.InnerText));
                    }
                }

                if (String.IsNullOrEmpty(chainName))
                {
                    throw new InvalidConfigException();
                }

                ChainObject[] objectsArr = new ChainObject[objects.Count];
                objects.CopyTo(objectsArr, 0);

                if (this.pipesChains.ContainsKey(chainName))
                {
                    this.pipesChains.Remove(chainName);
                }

                this.pipesChains.Add(chainName, objectsArr);
            }
        }
Exemplo n.º 3
0
 private void Awake()
 {
     rb = GetComponent <Rigidbody2D>();
     hj = GetComponent <HingeJoint2D>();
     tr = GetComponent <Transform>();
     sr = GetComponent <SpriteRenderer>();
     co = GetComponent <ChainObject>();
 }
 public void Append(ChainObject next)
 {
     _Next = next;
 }
 public ChainObject(ChainObject backRef)
 {
     _Title   = TestRandomizer.GetString();
     _BackRef = backRef;
 }