예제 #1
0
        protected override void OnNodeSet()
        {
            base.OnNodeSet();

            // we must register this document and get an id for it
            DomNode node   = this.DomNode;
            var     tag    = node.Type.GetTag(NativeAnnotations.NativeDocumentType);
            var     typeId = (tag != null) ? (uint)tag : 0;

            m_nativeDocId = GameEngine.CreateDocument(typeId);

            ManageNativeObjectLifeTime = true;
            foreach (var subnode in node.Subtree)
            {
                NativeObjectAdapter childObject = subnode.As <NativeObjectAdapter>();
                if (childObject != null)
                {
                    childObject.OnAddToDocument(this);

                    NativeObjectAdapter parentObject = subnode.Parent.As <NativeObjectAdapter>();
                    if (parentObject != null)
                    {
                        childObject.OnSetParent(parentObject, -1);
                    }
                }
            }

            node.ChildInserted += node_ChildInserted;
            node.ChildRemoved  += node_ChildRemoved;
        }
예제 #2
0
        private void node_ChildInserted_Internal(object child, object parent, int insertionPoint)
        {
            NativeObjectAdapter childObject = child.As <NativeObjectAdapter>();

            if (childObject != null)
            {
                childObject.OnAddToDocument(this);

                NativeObjectAdapter parentObject = parent.As <NativeObjectAdapter>();
                if (parentObject != null)
                {
                    childObject.OnSetParent(parentObject, insertionPoint);
                }
                else
                {
                    childObject.OnSetParent(null, -1);
                }
            }

            var children = child.As <DomNode>().Children;
            int index    = 0;

            foreach (var c in children)
            {
                node_ChildInserted_Internal(c, child, index);
                ++index;
            }
        }