Exemplo n.º 1
0
            private void ProcessSetterType(DomNode setter, string parentPropName,
                                           List <System.ComponentModel.PropertyDescriptor> descriptors)
            {
                string curPropName = (string)setter.GetAttribute(SkinSchema.setterType.propertyNameAttribute);

                if (string.IsNullOrWhiteSpace(curPropName))
                {
                    return;
                }
                string propName = !string.IsNullOrEmpty(parentPropName)
                    ? parentPropName + "->" + curPropName : curPropName;

                DomNode valInfo = setter.GetChild(SkinSchema.setterType.valueInfoChild);

                if (valInfo != null)
                {
                    ProcessValueInfo(valInfo, propName, descriptors);
                }

                DomNode listInfo = setter.GetChild(SkinSchema.setterType.listInfoChild);

                if (listInfo != null)
                {
                    foreach (var vInfo in listInfo.GetChildList(SkinSchema.listInfoType.valueInfoChild))
                    {
                        ProcessValueInfo(vInfo, propName, descriptors);
                    }
                }
            }
Exemplo n.º 2
0
        /// <summary>
        /// Inserts new object of given type using a transaction. Called by automated scripts during testing.</summary>
        /// <typeparam name="T">Type of object to insert</typeparam>
        /// <param name="insertingObject">DomNode that contains inserted object</param>
        /// <param name="insertionParent">Parent where object is inserted</param>
        /// <returns>Inserted object</returns>
        public T Insert <T>(DomNode insertingObject, DomNode insertionParent) where T : class
        {
            SetInsertionParent(insertionParent);
            insertingObject.SetAttribute(UISchema.UIType.nameAttribute, typeof(T).Name);
            DataObject dataObject = new DataObject(new object[] { insertingObject });

            ITransactionContext transactionContext = this.As <ITransactionContext>();

            transactionContext.DoTransaction(
                delegate
            {
                Insert(dataObject);
            }, "Scripted Insert Object");

            T         newItem   = null;
            ChildInfo childInfo = GetChildInfo(insertionParent, insertingObject.Type);

            if (childInfo != null)
            {
                if (childInfo.IsList)
                {
                    IList <DomNode> list = insertionParent.GetChildList(childInfo);
                    //This assumes the new object is always appended at the end of the list
                    DomNode newNode = list[list.Count - 1];
                    newItem = newNode.As <T>();
                }
                else
                {
                    DomNode newNode = insertionParent.GetChild(childInfo);
                    newItem = newNode.As <T>();
                }
            }

            return(newItem);
        }
Exemplo n.º 3
0
        public void TestAttributeChangesInTransaction()
        {
            DomNode child      = m_root.GetChild(ChildInfo);
            DomNode grandchild = child.GetChild(ChildInfo);

            // Combine 3 attribute change events into one.
            m_transactionContext.DoTransaction(() =>
            {
                grandchild.SetAttribute(StringAttrInfo, "foo1");
                grandchild.SetAttribute(StringAttrInfo, "foo2");
                grandchild.SetAttribute(StringAttrInfo, "foo3");
            }, "test transaction");

            Assert.IsTrue(m_events.Count == 1);
            CheckAttributeEvent(m_events[0], grandchild, "", "foo3");

            // Make sure that TransactionReporter clears its internal state correctly.
            // Test that multiple attribute change events that leave the original value
            //  equal to the final value do not raise a final attribute change event.
            grandchild.SetAttribute(StringAttrInfo, "foo1");
            m_events.Clear();
            m_transactionContext.DoTransaction(() =>
            {
                grandchild.SetAttribute(StringAttrInfo, "foo2");
                grandchild.SetAttribute(StringAttrInfo, "foo1");
            }, "test transaction 2");

            Assert.IsTrue(m_events.Count == 0);
        }
Exemplo n.º 4
0
Arquivo: Tools.cs Projeto: zparr/ATF
        /// <summary>
        /// Creates effects dictionary</summary>
        /// <param name="bindMtrl">Bind material DomNode</param>
        /// <returns>Effects dictionary of string/Effect pairs</returns>
        public static Dictionary <string, Effect> CreateEffectDictionary(DomNode bindMtrl)
        {
            if (bindMtrl == null)
            {
                return(null);
            }

            var result = new Dictionary <string, Effect>();

            DomNode techCommon = bindMtrl.GetChild(Schema.bind_material.technique_commonChild);

            IList <DomNode> instMtrls = techCommon.GetChildList(Schema.bind_material_technique_common.instance_materialChild);

            foreach (DomNode instMtrl in instMtrls)
            {
                DomNode material   = instMtrl.GetAttribute(Schema.instance_material.targetAttribute).As <DomNode>();
                DomNode instEffect = material.GetChild(Schema.material.instance_effectChild);
                Effect  effect     = instEffect.GetAttribute(Schema.instance_effect.urlAttribute).As <Effect>();

                string symbol = instMtrl.GetAttribute(Schema.instance_material.symbolAttribute) as string;
                if (!String.IsNullOrEmpty(symbol))
                {
                    result.Add(symbol, effect);
                }
            }

            return((result.Count > 0) ? result : null);
        }
Exemplo n.º 5
0
        private bool Equals(DomNode n1, DomNode n2)
        {
            if (n1 == null || n2 == null)
            {
                return(n1 == n2);
            }
            if (n1.Type != n2.Type)
            {
                return(false);
            }
            if (n1.ChildInfo != n2.ChildInfo)
            {
                return(false);
            }

            foreach (AttributeInfo info in n1.Type.Attributes)
            {
                object val1 = n1.GetLocalAttribute(info);
                object val2 = n2.GetLocalAttribute(info);
                if (val1 == null || val2 == null)
                {
                    if (val1 != val2)
                    {
                        return(false);
                    }
                }
            }

            foreach (ChildInfo info in n1.Type.Children)
            {
                if (info.IsList)
                {
                    IList <DomNode> children1 = n1.GetChildList(info);
                    IList <DomNode> children2 = n1.GetChildList(info);
                    if (children1.Count != children2.Count)
                    {
                        return(false);
                    }
                    for (int i = 0; i < children1.Count; i++)
                    {
                        if (!Equals(children1[i], children2[i]))
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    DomNode child1 = n1.GetChild(info);
                    DomNode child2 = n2.GetChild(info);
                    if (!Equals(child1, child2))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Exemplo n.º 6
0
            public Prototype(DomNode node, Uri ur)
            {
                m_node = node;
                m_uri  = ur;
                IGameObject gob = m_node.GetChild(Schema.prototypeType.gameObjectChild).As <IGameObject>();

                gob.Name = Type + "_" + Path.GetFileNameWithoutExtension(ur.LocalPath);
            }
Exemplo n.º 7
0
        private void SetVector(DomNode domNode, ChildInfo metaElement, AttributeInfo attributeInfo, Vec3F v)
        {
            if (domNode == null)
            {
                domNode = DomNode.GetChild(metaElement);
            }

            DomNodeUtil.SetVector(domNode, attributeInfo, v);
        }
        /// <summary>
        /// Performs initialization when the adapter's node is set.
        /// This method is called each time the adapter is connected to its underlying node.
        /// Typically overridden by creators of DOM adapters.</summary>
        protected override void OnNodeSet()
        {
            base.OnNodeSet();

            DomNode controller = DomNode.GetAttribute(Schema.instance_controller.urlAttribute).As <DomNode>();
            DomNode skin       = controller.GetChild(Schema.controller.skinChild);

            Geometry = skin.GetAttribute(Schema.skin.sourceAttribute).As <Geometry>();

            Geometry.Effects = Tools.CreateEffectDictionary(GetChild <DomNode>(Schema.instance_controller.bind_materialChild));
        }
Exemplo n.º 9
0
        /// <summary>
        /// Performs initialization when the adapter is connected to the diagram annotation's DomNode,
        /// creating child DomNode for transform and setting its scale.</summary>
        protected override void OnNodeSet()
        {
            DomNode transform = DomNode.GetChild(UISchema.UIControlType.TransformChild);

            if (transform == null)
            {
                transform = new DomNode(UISchema.UITransformType.Type);
                transform.SetAttribute(UISchema.UITransformType.ScaleAttribute, new float[] { 1.0f, 1.0f, 1.0f });
                DomNode.SetChild(UISchema.UIControlType.TransformChild, transform);
            }
        }
Exemplo n.º 10
0
            private void ProcessValueInfo(DomNode valInfo, string propName,
                                          List <System.ComponentModel.PropertyDescriptor> descriptors)
            {
                string typeName = (string)valInfo.GetAttribute(SkinSchema.valueInfoType.typeAttribute);
                Type   type     = SkinUtil.GetType(typeName);


                if (type == typeof(Font))
                {
                    FontDescriptor descr
                        = new FontDescriptor(valInfo, propName, null, null, null, null);
                    descriptors.Add(descr);
                }
                else
                {
                    TypeConverter converter;
                    object        editor;
                    GetEditorAndConverter(type, out editor, out converter);
                    if (editor != null)
                    {
                        var descr = new SkinSetterAttributePropertyDescriptor(valInfo
                                                                              , propName, SkinSchema.valueInfoType.valueAttribute, null, null, false, editor, converter);
                        descriptors.Add(descr);
                    }
                    else
                    {
                        DomNode ctorParams = valInfo.GetChild(SkinSchema.valueInfoType.constructorParamsChild);
                        if (ctorParams != null)
                        {
                            var vInfoChildList = ctorParams.GetChildList(SkinSchema.constructorParamsType.valueInfoChild);
                            if (vInfoChildList.Count == 1)
                            {
                                ProcessValueInfo(vInfoChildList[0], propName, descriptors);
                            }
                            else
                            {
                                int    k         = 1;
                                string paramName = propName + " : Arg_";
                                foreach (DomNode vInfoChild in vInfoChildList)
                                {
                                    string name = paramName + k;
                                    ProcessValueInfo(vInfoChild, name, descriptors);
                                    k++;
                                }
                            }
                        }

                        foreach (DomNode setterChild in valInfo.GetChildList(SkinSchema.valueInfoType.setterChild))
                        {
                            ProcessSetterType(setterChild, propName, descriptors);
                        }
                    }
                }
            }
Exemplo n.º 11
0
Arquivo: Tools.cs Projeto: Joxx0r/ATF
        /// <summary>
        /// Returns DomNode's color components in array</summary>
        /// <param name="domNode">DomNode whose color is obtained</param>
        /// <returns>Array of DomNode's color components</returns>
        public static float[] GetColor(DomNode domNode)
        {
            float[] value = null;
            if (domNode != null)
            {
                DomNode color = domNode.GetChild(Schema.common_color_or_texture_type.colorChild);
                if (color != null)
                    value = DoubleToFloat(color.GetAttribute(Schema.common_color_or_texture_type_color.Attribute) as double[]);
            }

            return value;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Gets the child described by the given child metadata</summary>
        /// <typeparam name="T">The type to adapt the child DomNode to</typeparam>
        /// <param name="childInfo">Metadata to indicate which child type to look for</param>
        /// <returns>The child DomNode, adapted to the given type, or null</returns>
        protected T GetChild <T>(ChildInfo childInfo)
            where T : class
        {
            DomNode child = DomNode.GetChild(childInfo);

            if (child != null)
            {
                return(child.As <T>());
            }

            return(null);
        }
Exemplo n.º 13
0
        public void TestOnAttributeSet()
        {
            DomNode   root       = CreateTree();
            Validator validator  = root.As <Validator>();
            DomNode   grandchild = root.GetChild(m_childInfo).GetChild(m_childInfo);

            grandchild.SetAttribute(m_stringAttrInfo, "foo");
            Assert.AreSame(validator.Sender, root);
            AttributeEventArgs e = (AttributeEventArgs)validator.E;

            Assert.NotNull(e);
            Assert.AreSame(e.DomNode, grandchild);
        }
Exemplo n.º 14
0
        public void TestGetChildList()
        {
            DomNodeType type      = new DomNodeType("type");
            ChildInfo   childInfo = new ChildInfo("child", type, true);

            type.Define(childInfo);

            DomNode         parent = new DomNode(type);
            IList <DomNode> list   = parent.GetChildList(childInfo);

            Assert.NotNull(list);
            Assert.Throws <InvalidOperationException>(delegate { parent.GetChild(childInfo); });
            CollectionAssert.IsEmpty(list);
        }
Exemplo n.º 15
0
Arquivo: Tools.cs Projeto: zparr/ATF
        /// <summary>
        /// Returns DomNode's color components in array</summary>
        /// <param name="domNode">DomNode whose color is obtained</param>
        /// <returns>Array of DomNode's color components</returns>
        public static float[] GetColor(DomNode domNode)
        {
            float[] value = null;
            if (domNode != null)
            {
                DomNode color = domNode.GetChild(Schema.common_color_or_texture_type.colorChild);
                if (color != null)
                {
                    value = DoubleToFloat(color.GetAttribute(Schema.common_color_or_texture_type_color.Attribute) as double[]);
                }
            }

            return(value);
        }
Exemplo n.º 16
0
        public void TestGetChild()
        {
            DomNodeType type      = new DomNodeType("type");
            ChildInfo   childInfo = new ChildInfo("child", type);

            type.Define(childInfo);

            DomNode parent = new DomNode(type);
            DomNode child  = new DomNode(type);

            parent.SetChild(childInfo, child);
            Assert.AreSame(parent.GetChild(childInfo), child);
            Assert.Throws <InvalidOperationException>(delegate { parent.GetChildList(childInfo); });
        }
Exemplo n.º 17
0
        void ICommandClient.DoCommand(object commandTag)
        {
            if (!(commandTag is Command))
            {
                return;
            }

            switch ((Command)commandTag)
            {
            case Command.CreateTerrain:
            {
                if (DomNode.GetChild(Schema.xleGameType.terrainChild) == null)
                {
                    var newNode = LevelEditorXLE.Terrain.XLETerrainGob.CreateWithConfigure();
                    if (newNode != null)
                    {
                        DomNode.SetChild(Schema.xleGameType.terrainChild, newNode);
                    }
                }
                break;
            }

            case Command.CreatePlacementsFolder:
            {
                if (DomNode.GetChild(Schema.xleGameType.placementsChild) == null)
                {
                    var newNode = PlacementsFolder.CreateWithConfigure();
                    if (newNode != null)
                    {
                        DomNode.SetChild(Schema.xleGameType.placementsChild, newNode);
                    }
                }
                break;
            }

            case Command.CreateEnvironmentSetting:
            {
                var envFolder = EnvSettingsFolder;
                envFolder.AddChild(
                    XLEEnvSettings.Create(envFolder.GetNameForNewChild()));
                break;
            }

            case Command.CreateTriMeshMarker:
            {
                this.As <IGame>().RootGameObjectFolder.As <IHierarchical>().AddChild(Markers.TriMeshMarker.Create());
                break;
            }
            }
        }
Exemplo n.º 18
0
Arquivo: Tools.cs Projeto: zparr/ATF
        /// <summary>
        /// Gets float value associated with DomNode</summary>
        /// <param name="domNode">DomNode whose value is obtained</param>
        /// <returns>Float value associated with DomNode</returns>
        public static float GetFloat(DomNode domNode)
        {
            float value = default(float);

            if (domNode != null)
            {
                DomNode floatChild = domNode.GetChild(Schema.common_float_or_param_type.floatChild);
                if (floatChild != null)
                {
                    double v = (double)floatChild.GetAttribute(Schema.common_float_or_param_type_float.Attribute);
                    value = (float)v;
                }
            }
            return(value);
        }
Exemplo n.º 19
0
        public void TestAttributeChangesNoTransaction()
        {
            DomNode child      = m_root.GetChild(ChildInfo);
            DomNode grandchild = child.GetChild(ChildInfo);

            grandchild.SetAttribute(StringAttrInfo, "foo1");
            grandchild.SetAttribute(StringAttrInfo, "foo2");
            grandchild.SetAttribute(StringAttrInfo, "foo3");

            // Because there's no transaction, each DOM change event should yield a TransactionFinishedXxx event.
            Assert.IsTrue(m_events.Count == 3);
            CheckAttributeEvent(m_events[0], grandchild, "", "foo1");
            CheckAttributeEvent(m_events[1], grandchild, "foo1", "foo2");
            CheckAttributeEvent(m_events[2], grandchild, "foo2", "foo3");
        }
Exemplo n.º 20
0
        /// <summary>
        /// When overridden in a derived class, gets the result value of the property on a component</summary>
        /// <param name="component">The component with the property for which to retrieve the value</param>
        /// <returns>The value of a property for a given component.</returns>
        public override object GetValue(object component)
        {
            DomNode node = GetNode(component);

            if (node != null &&
                node.Type.IsValid(m_childInfo))
            {
                if (m_childInfo.IsList)
                {
                    return(node.GetChildList(m_childInfo));
                }
                return(node.GetChild(m_childInfo));
            }

            return(null);
        }
Exemplo n.º 21
0
        /// <summary>
        /// Gets the children of the given parent object</summary>
        /// <param name="parent">Parent object</param>
        /// <returns>Children of the parent object</returns>
        public IEnumerable <object> GetChildren(object parent)
        {
            DomNode node = parent as DomNode;

            if (node != null)
            {
                // get child Dom nodes and empty reference "slots"
                foreach (ChildInfo childInfo in node.Type.Children)
                {
                    // skip over control points.
                    if (childInfo == UISchema.curveType.controlPointChild)
                    {
                        continue;
                    }

                    // skip over UITransformType
                    if (childInfo.Type == UISchema.UITransformType.Type)
                    {
                        continue;
                    }

                    if (childInfo.IsList)
                    {
                        foreach (DomNode child in node.GetChildList(childInfo))
                        {
                            yield return(child);
                        }
                    }
                    else
                    {
                        DomNode child = node.GetChild(childInfo);
                        if (child != null)
                        {
                            yield return(child);
                        }
                        else if (childInfo.Type == UISchema.UIRefType.Type)
                        {
                            yield return(new EmptyRef(node, childInfo));
                        }
                    }
                }
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Gets DOM object from component</summary>
        /// <param name="component">Component being edited</param>
        /// <returns>DomNode</returns>
        public override DomNode GetNode(object component)
        {
            DomNode domNode = component.As <DomNode>();

            if (domNode != null)
            {
                // Check that the meta element path exists on the parent DOM object
                foreach (ChildInfo childInfo in m_childInfos)
                {
                    ChildInfo classMeta = domNode.Type.GetChildInfo(childInfo.Name);

                    if (classMeta != null)
                    {
                        return(domNode.GetChild(classMeta));
                    }
                }
            }

            return(domNode);
        }
Exemplo n.º 23
0
        protected override void OnNodeSet()
        {
            base.OnNodeSet();

            var gameDocRegistry = Globals.MEFContainer.GetExportedValue <GameDocumentRegistry>();

            if (gameDocRegistry.MasterDocument == null || gameDocRegistry.MasterDocument == this.As <IGameDocument>())
            {
                m_layerRoot = DomNode.GetChild(Schema.gameType.layersChild);
                m_layers    = new DomNodeListAdapter <ILayer>(m_layerRoot, Schema.layersType.layerChild);

                m_layerRoot.ChildInserted    += DomNode_ChildInserted;
                m_layerRoot.ChildRemoved     += DomNode_ChildRemoved;
                m_layerRoot.AttributeChanged += DomNode_AttributeChanged;
                GameContext        gameContext       = DomNode.Cast <GameContext>();
                IValidationContext validationContext = (IValidationContext)gameContext;
                validationContext.Ended += validationContext_Ended;
                m_activeItem             = m_layerRoot;
            }
        }
Exemplo n.º 24
0
        public void TestDomChangesInTransaction()
        {
            DomNode child      = m_root.GetChild(ChildInfo);
            DomNode grandchild = child.GetChild(ChildInfo);

            // Remove and then add the parent of the DomNode whose attributes get changed.
            m_transactionContext.DoTransaction(() =>
            {
                grandchild.SetAttribute(StringAttrInfo, "foo1");
                grandchild.SetAttribute(StringAttrInfo, "foo2");
                grandchild.SetAttribute(StringAttrInfo, "foo3");
                child.RemoveFromParent();
                m_root.SetChild(ChildInfo, child);
                grandchild.SetAttribute(StringAttrInfo, "foo4");
            }, "test transaction");

            Assert.IsTrue(m_events.Count == 2);
            CheckChildRemovedEvent(m_events[0], m_root, child);
            CheckChildInsertedEvent(m_events[1], m_root, child);
        }
Exemplo n.º 25
0
        public void TestDomChangesNoTransaction()
        {
            DomNode child      = m_root.GetChild(ChildInfo);
            DomNode grandchild = child.GetChild(ChildInfo);

            grandchild.SetAttribute(StringAttrInfo, "foo1");
            grandchild.SetAttribute(StringAttrInfo, "foo2");
            grandchild.SetAttribute(StringAttrInfo, "foo3");
            child.RemoveFromParent();
            m_root.SetChild(ChildInfo, child);
            grandchild.SetAttribute(StringAttrInfo, "foo4");

            // Because there's no transaction, each DOM change event should yield a TransactionFinishedXxx event.
            Assert.IsTrue(m_events.Count == 6);
            CheckAttributeEvent(m_events[0], grandchild, "", "foo1");
            CheckAttributeEvent(m_events[1], grandchild, "foo1", "foo2");
            CheckAttributeEvent(m_events[2], grandchild, "foo2", "foo3");
            CheckChildRemovedEvent(m_events[3], m_root, child);
            CheckChildInsertedEvent(m_events[4], m_root, child);
            CheckAttributeEvent(m_events[5], grandchild, "foo3", "foo4");
        }
Exemplo n.º 26
0
        bool ICommandClient.CanDoCommand(object commandTag)
        {
            if (commandTag is Command)
            {
                switch ((Command)commandTag)
                {
                case Command.CreateTerrain:
                    return(DomNode.GetChild(Schema.xleGameType.terrainChild) == null);

                case Command.CreatePlacementsFolder:
                    return(DomNode.GetChild(Schema.xleGameType.placementsChild) == null);

                case Command.CreateEnvironmentSetting:
                    return(true);

                case Command.CreateTriMeshMarker:
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 27
0
        /// <summary>
        /// Performs custom actions on NodeSet events.
        /// Called after successfully attaching to internal DOM object.</summary>
        protected override void OnNodeSet()
        {
            base.OnNodeSet();

            // Initialize scale to (1, 1, 1) if missing
            DomNode.SetAttributeIfDefault(Schema.nodeType.scaleAttribute, new Vec3F(1, 1, 1));

            m_rotation     = DomNode.GetChild(Schema.nodeType.rotEulChild);
            m_rotationAxis = DomNode.GetChild(Schema.nodeType.rotAxisEulChild);
            Transform      = TransformUtils.CalcTransform(this);

            Box boxValue = DomNodeUtil.GetBox(DomNode, Schema.nodeType.boundingBoxAttribute);

            if (boxValue.IsEmpty)
            {
                m_boundingBox = new Cached <Box>(CalculateBoundingBox); // don't set value and force to compute
            }
            else
            {
                m_boundingBox = new Cached <Box>(CalculateBoundingBox, boxValue); // non-default value found, use it
            }
        }
Exemplo n.º 28
0
        public void TestRemoveFromParent()
        {
            DomNodeType type      = new DomNodeType("type");
            ChildInfo   childInfo = new ChildInfo("child", type);

            type.Define(childInfo);
            DomNode parent = new DomNode(type);
            DomNode child  = new DomNode(type);

            parent.SetChild(childInfo, child);
            child.RemoveFromParent();
            Assert.Null(parent.GetChild(childInfo));
            Assert.Null(child.Parent);

            // Make sure the removed child has a null Parent. http://tracker.ship.scea.com/jira/browse/WWSATF-1336
            parent.SetChild(childInfo, child);
            DomNode newChild = new DomNode(type);

            parent.SetChild(childInfo, newChild);
            Assert.Null(child.Parent);
            Assert.True(newChild.Parent == parent);
        }
Exemplo n.º 29
0
 /// <summary>
 /// Writes the child elements recursively</summary>
 /// <param name="node">DomNode to write</param>
 /// <param name="writer">The XML writer. See <see cref="T:System.Xml.XmlWriter"/>.</param>
 protected virtual void WriteChildElementsRecursive(DomNode node, XmlWriter writer)
 {
     // write child elements
     foreach (ChildInfo childInfo in node.Type.Children)
     {
         if (childInfo.IsList)
         {
             foreach (DomNode child in node.GetChildList(childInfo))
             {
                 WriteElement(child, writer);
             }
         }
         else
         {
             DomNode child = node.GetChild(childInfo);
             if (child != null)
             {
                 WriteElement(child, writer);
             }
         }
     }
 }
Exemplo n.º 30
0
        public void TestReparentInTransaction()
        {
            DomNode a = m_root.GetChild(ChildInfo);
            DomNode b = a.GetChild(ChildInfo);

            b.RemoveFromParent();

            // root -- a  ==>
            // root -- b -- a
            m_events.Clear();
            m_transactionContext.DoTransaction(() =>
            {
                a.SetAttribute(StringAttrInfo, "foo1");
                a.RemoveFromParent();
                m_root.SetChild(ChildInfo, b);
                b.SetChild(ChildInfo, a);
                b.SetAttribute(StringAttrInfo, "foo1");
            }, "test transaction 1");

            Assert.IsTrue(m_events.Count == 2);
            CheckChildRemovedEvent(m_events[0], m_root, a);
            CheckChildInsertedEvent(m_events[1], m_root, b);
        }
Exemplo n.º 31
0
Arquivo: Tools.cs Projeto: Joxx0r/ATF
        /// <summary>
        /// Creates effects dictionary</summary>
        /// <param name="bindMtrl">Bind material DomNode</param>
        /// <returns>Effects dictionary of string/Effect pairs</returns>
        public static Dictionary<string, Effect> CreateEffectDictionary(DomNode bindMtrl)
        {
            if (bindMtrl == null)
                return null;

            var result = new Dictionary<string, Effect>();

            DomNode techCommon = bindMtrl.GetChild(Schema.bind_material.technique_commonChild);

            IList<DomNode> instMtrls = techCommon.GetChildList(Schema.bind_material_technique_common.instance_materialChild);
            foreach (DomNode instMtrl in instMtrls)
            {
                DomNode material = instMtrl.GetAttribute(Schema.instance_material.targetAttribute).As<DomNode>();
                DomNode instEffect = material.GetChild(Schema.material.instance_effectChild);
                Effect effect = instEffect.GetAttribute(Schema.instance_effect.urlAttribute).As<Effect>();

                string symbol = instMtrl.GetAttribute(Schema.instance_material.symbolAttribute) as string;
                if (!String.IsNullOrEmpty(symbol))
                    result.Add(symbol, effect);
            }

            return (result.Count > 0) ? result : null;
        }
Exemplo n.º 32
0
        public void TestGetChild()
        {
            DomNodeType type = new DomNodeType("type");
            ChildInfo childInfo = new ChildInfo("child", type);
            type.Define(childInfo);

            DomNode parent = new DomNode(type);
            DomNode child = new DomNode(type);
            parent.SetChild(childInfo, child);
            Assert.AreSame(parent.GetChild(childInfo), child);
            Assert.Throws<InvalidOperationException>(delegate { parent.GetChildList(childInfo); });
        }
Exemplo n.º 33
0
        protected override void OnNodeSet()
        {
            base.OnNodeSet();

            if (string.IsNullOrEmpty(GetAttribute <string>(moduleType.labelAttribute)))
            {
                SetAttribute(moduleType.labelAttribute, GetAttribute <string>(moduleType.nameAttribute));
            }

            // Pull image icon image from node definition
            var nodeDef = DomNode.Type.GetTag <SF.Tong.Schema.NodeTypeInfo>();

            m_Image = string.IsNullOrEmpty(nodeDef.Icon) ? null : ResourceUtil.GetImage32(nodeDef.Icon);

            // Create non-string child classes
            if (DomNode.Children != null)
            {
                foreach (var childInfo in DomNode.Type.Children)
                {
                    if (childInfo.IsList)
                    {
                        continue;
                    }
                    if (DomNode.GetChild(childInfo) != null)
                    {
                        continue;
                    }

                    var newChild = new DomNode(childInfo.Type);
                    DomNode.SetChild(childInfo, newChild);
                }
            }

            // Add sockets for attributes
            if (DomNode.Type.Attributes != null)
            {
                foreach (var attrInfo in DomNode.Type.Attributes)
                {
                    var attrRule = attrInfo.GetRule <GameDataAttributeRule>();
                    if (attrRule == null || attrRule.SchemaProperty == null)
                    {
                        continue;
                    }

                    switch (attrRule.SchemaProperty.Socket)
                    {
                    case SF.Tong.Schema.SocketType.Input:
                        m_Inputs.Add(new ElementType.Pin(attrInfo.Name, attrInfo.Type, m_Inputs.Count, allowFanIn: attrRule.SchemaProperty.AllowMultipleInput));
                        break;

                    case SF.Tong.Schema.SocketType.Output:
                        m_Outputs.Add(new ElementType.Pin(attrInfo.Name, attrInfo.Type, m_Outputs.Count, allowFanOut: attrRule.SchemaProperty.AllowMultipleOutput));
                        break;

                    case SF.Tong.Schema.SocketType.InOut:
                        m_Inputs.Add(new ElementType.Pin(attrInfo.Name, attrInfo.Type, m_Inputs.Count, allowFanIn: attrRule.SchemaProperty.AllowMultipleInput));
                        m_Outputs.Add(new ElementType.Pin(attrInfo.Name, attrInfo.Type, m_Outputs.Count, allowFanOut: attrRule.SchemaProperty.AllowMultipleOutput));
                        break;

                    default:
                        break;
                    }
                }
            }


            // Create child sockets
            if (DomNode.Children != null)
            {
                foreach (var child in DomNode.Children)
                {
                    if (child.ChildInfo.Type != socketType.Type)
                    {
                        continue;
                    }

                    string socketName = GetBaseNameFor(child.ChildInfo, child);

                    // Only output can vary
                    var newPin = new ElementType.Pin(socketName, AttributeType.BooleanType, m_Outputs.Count);
                    m_Outputs.Add(newPin);
                }
            }


            // Update socket as new a child node is added
            DomNode.ChildInserted += (sender, args) =>
            {
                if (DomNode != args.Parent)
                {
                    return;
                }

                if (args.ChildInfo.Type == socketType.Type)
                {
                    string socketName = GetBaseNameFor(args.ChildInfo, args.Child);

                    // Only output can vary
                    var newPin = new ElementType.Pin(socketName, AttributeType.BooleanType, m_Outputs.Count);
                    m_Outputs.Add(newPin);
                }
            };

            // Update socket as new a child node is removed
            DomNode.ChildRemoved += (sender, args) =>
            {
                if (DomNode != args.Parent)
                {
                    return;
                }

                if (args.ChildInfo.Type == socketType.Type)
                {
                    string socketName = GetBaseNameFor(args.ChildInfo, args.Child);

                    // Only output can vary
                    int iSocket = 0;
                    for (; iSocket < m_Outputs.Count; iSocket++)
                    {
                        var output = m_Outputs[iSocket];
                        if (output.Name == socketName)
                        {
                            m_Outputs.RemoveAt(iSocket);
                            break;
                        }
                    }

                    // fix up index
                    for (; iSocket < m_Outputs.Count; iSocket++)
                    {
                        var output = m_Outputs[iSocket];
                        output.Index = iSocket;
                    }
                }
            };

            // For title text
            UpdateTitleText();

            DomNode.AttributeChanged += OnAttributeChanged;
        }
Exemplo n.º 34
0
            private void ProcessSetterType(DomNode setter, string parentPropName,
                List<System.ComponentModel.PropertyDescriptor> descriptors)
            {
                string curPropName = (string)setter.GetAttribute(SkinSchema.setterType.propertyNameAttribute);
                if (string.IsNullOrWhiteSpace(curPropName)) return;
                string propName = !string.IsNullOrEmpty(parentPropName)
                    ? parentPropName + "->" + curPropName : curPropName;

                DomNode valInfo = setter.GetChild(SkinSchema.setterType.valueInfoChild);
                if (valInfo != null)
                {
                    ProcessValueInfo(valInfo, propName, descriptors);
                }

                DomNode listInfo = setter.GetChild(SkinSchema.setterType.listInfoChild);
                if (listInfo != null)
                {
                    foreach (var vInfo in listInfo.GetChildList(SkinSchema.listInfoType.valueInfoChild))
                        ProcessValueInfo(vInfo, propName, descriptors);
                }
            }
Exemplo n.º 35
0
 /// <summary>
 /// Writes the child elements recursively</summary>
 /// <param name="node">DomNode to write</param>
 /// <param name="writer">The XML writer. See <see cref="T:System.Xml.XmlWriter"/>.</param>
 protected virtual void WriteChildElementsRecursive(DomNode node, XmlWriter writer)
 {
     // write child elements
     foreach (ChildInfo childInfo in node.Type.Children)
     {
         if (childInfo.IsList)
         {
             foreach (DomNode child in node.GetChildList(childInfo))
                 WriteElement(child, writer);
         }
         else
         {
             DomNode child = node.GetChild(childInfo);
             if (child != null)
                 WriteElement(child, writer);
         }
     }
 }
Exemplo n.º 36
0
            private void ProcessValueInfo(DomNode valInfo, string propName,
                List<System.ComponentModel.PropertyDescriptor> descriptors)
            {
                string typeName = (string)valInfo.GetAttribute(SkinSchema.valueInfoType.typeAttribute);
                Type type = SkinUtil.GetType(typeName);


                if (type == typeof(Font))
                {
                    FontDescriptor descr
                        = new FontDescriptor(valInfo, propName, null, null, null, null);
                    descriptors.Add(descr);
                }
                else
                {

                    TypeConverter converter;
                    object editor;
                    GetEditorAndConverter(type, out editor, out converter);
                    if (editor != null)
                    {
                        var descr = new SkinSetterAttributePropertyDescriptor(valInfo
                            , propName, SkinSchema.valueInfoType.valueAttribute, null, null, false, editor, converter);
                        descriptors.Add(descr);
                    }
                    else
                    {
                        DomNode ctorParams = valInfo.GetChild(SkinSchema.valueInfoType.constructorParamsChild);
                        if (ctorParams != null)
                        {
                            var vInfoChildList = ctorParams.GetChildList(SkinSchema.constructorParamsType.valueInfoChild);
                            if (vInfoChildList.Count == 1)
                            {
                                ProcessValueInfo(vInfoChildList[0], propName, descriptors);
                            }
                            else
                            {

                                // special handling for SyntaxEditorControl
                                if (typeName == "Sce.Atf.Controls.SyntaxEditorControl.TextHighlightStyle")
                                {
                                    string argName =
                                    (string)vInfoChildList[0].GetAttribute(SkinSchema.valueInfoType.valueAttribute);

                                    string name = propName + "->" + argName;
                                    ProcessValueInfo(vInfoChildList[1], name, descriptors);
                                }
                                else
                                {
                                    int k = 1;
                                    string paramName = propName + " : Arg_";
                                    foreach (DomNode vInfoChild in vInfoChildList)
                                    {
                                        string name = paramName + k;
                                        ProcessValueInfo(vInfoChild, name, descriptors);
                                        k++;
                                    }
                                }
                            }
                        }

                        foreach (DomNode setterChild in valInfo.GetChildList(SkinSchema.valueInfoType.setterChild))
                        {
                            ProcessSetterType(setterChild, propName, descriptors);
                        }
                    }
                }
            }
Exemplo n.º 37
0
        private bool Equals(DomNode n1, DomNode n2)
        {
            if (n1 == null || n2 == null)
                return n1 == n2;
            if (n1.Type != n2.Type)
                return false;
            if (n1.ChildInfo != n2.ChildInfo)
                return false;

            foreach (AttributeInfo info in n1.Type.Attributes)
            {
                object val1 = n1.GetLocalAttribute(info);
                object val2 = n2.GetLocalAttribute(info);
                if (val1 == null || val2 == null)
                    if (val1 != val2)
                        return false;
            }

            foreach (ChildInfo info in n1.Type.Children)
            {
                if (info.IsList)
                {
                    IList<DomNode> children1 = n1.GetChildList(info);
                    IList<DomNode> children2 = n1.GetChildList(info);
                    if (children1.Count != children2.Count)
                        return false;
                    for (int i = 0; i < children1.Count; i++)
                        if (!Equals(children1[i], children2[i]))
                            return false;
                }
                else
                {
                    DomNode child1 = n1.GetChild(info);
                    DomNode child2 = n2.GetChild(info);
                    if (!Equals(child1, child2))
                        return false;
                }
            }

            return true;
        }
Exemplo n.º 38
0
        public void TestRemoveFromParent()
        {
            DomNodeType type = new DomNodeType("type");
            ChildInfo childInfo = new ChildInfo("child", type);
            type.Define(childInfo);
            DomNode parent = new DomNode(type);
            DomNode child = new DomNode(type);
            parent.SetChild(childInfo, child);
            child.RemoveFromParent();
            Assert.Null(parent.GetChild(childInfo));
            Assert.Null(child.Parent);

            // Make sure the removed child has a null Parent. http://tracker.ship.scea.com/jira/browse/WWSATF-1336
            parent.SetChild(childInfo, child);
            DomNode newChild = new DomNode(type);
            parent.SetChild(childInfo, newChild);
            Assert.Null(child.Parent);
            Assert.True(newChild.Parent == parent);
        }
Exemplo n.º 39
0
        private static void Serialize(DomNode node, Dictionary<DomNode, int> nodeIds, BinaryWriter writer)
        {
            writer.Write(node.Type.Name);

            foreach (AttributeInfo info in node.Type.Attributes)
            {
                object value = node.GetLocalAttribute(info);

                // references are serialized as an integer id
                if (info.Type.Type == AttributeTypes.Reference)
                {
                    DomNode reference = value as DomNode;
                    int refId;
                    if (reference == null ||
                        !nodeIds.TryGetValue(reference, out refId))
                    {
                        // null, or reference was external to top level nodes and their subtrees
                        writer.Write(false);
                    }
                    else
                    {
                        writer.Write(true);
                        writer.Write(refId);
                    }
                }
                else
                {
                    if (value == null)
                    {
                        writer.Write(false);
                    }
                    else
                    {
                        writer.Write(true);
                        writer.Write(info.Type.Convert(value));
                    }
                }
            }

            foreach (ChildInfo info in node.Type.Children)
            {
                if (info.IsList)
                {
                    IList<DomNode> children = node.GetChildList(info);
                    writer.Write(children.Count);
                    foreach (DomNode child in children)
                        Serialize(child, nodeIds, writer);
                }
                else
                {
                    DomNode child = node.GetChild(info);
                    if (child == null)
                    {
                        writer.Write(false);
                    }
                    else
                    {
                        writer.Write(true);
                        Serialize(child, nodeIds, writer);
                    }
                }
            }
        }
Exemplo n.º 40
0
        /// <summary>
        /// Writes the element corresponding to the DomNode</summary>
        /// <param name="node">DomNode to write</param>
        protected virtual void WriteElement(DomNode node, XmlWriter writer)
        {
            string elementNS = m_typeCollection.TargetNamespace;
            int index = node.ChildInfo.Name.LastIndexOf(':');
            if (index >= 0)
                elementNS = node.ChildInfo.Name.Substring(0, index);

            string elementPrefix = string.Empty;

            // is this the root DomNode?
            if (node.Parent == null)
            {
                elementPrefix = m_typeCollection.GetPrefix(elementNS);
                if (elementPrefix == null)
                    elementPrefix = GeneratePrefix(elementNS);

                writer.WriteStartElement(elementPrefix, node.ChildInfo.Name, elementNS);

                // define the xsi namespace
                writer.WriteAttributeString("xmlns", "xsi", null, XmlSchema.InstanceNamespace);

                // define schema namespaces
                foreach (XmlQualifiedName name in m_typeCollection.Namespaces)
                    if (name.Name != elementPrefix) // don't redefine the element namespace
                        writer.WriteAttributeString("xmlns", name.Name, null, name.Namespace);
            }
            else
            {
                // not the root, so all schema namespaces have been defined
                elementPrefix = writer.LookupPrefix(elementNS);
                if (elementPrefix == null)
                    elementPrefix = GeneratePrefix(elementNS);

                writer.WriteStartElement(elementPrefix, node.ChildInfo.Name, elementNS);
            }

            // write type name if this is a polymorphic type
            DomNodeType type = node.Type;
            if (node.ChildInfo.Type != type)
            {
                string name = type.Name;
                index = name.LastIndexOf(':');
                if (index >= 0)
                {
                    string typeName = name.Substring(index + 1, type.Name.Length - index - 1);
                    string typeNS = name.Substring(0, index);
                    string typePrefix = writer.LookupPrefix(typeNS);
                    if (typePrefix == null)
                    {
                        typePrefix = GeneratePrefix(typeNS);
                        writer.WriteAttributeString("xmlns", typePrefix, null, typeNS);
                    }

                    name = typeName;
                    if (typePrefix != string.Empty)
                        name = typePrefix + ":" + typeName;
                }

                writer.WriteAttributeString("xsi", "type", XmlSchema.InstanceNamespace, name);
            }

            // write attributes
            AttributeInfo valueAttribute = null;
            foreach (AttributeInfo attributeInfo in type.Attributes)
            {
                // if attribute is required, or not the default, write it
                if (/*attributeInfo.Required ||*/ !node.IsAttributeDefault(attributeInfo))
                {
                    if (attributeInfo.Name == string.Empty)
                    {
                        valueAttribute = attributeInfo;
                    }
                    else
                    {
                        object value = node.GetAttribute(attributeInfo);
                        string valueString = null;
                        if (attributeInfo.Type.Type == AttributeTypes.Reference)
                        {
                            // if reference is a valid node, convert to string
                            DomNode refNode = value as DomNode;
                            if (refNode != null)
                                valueString = GetNodeReferenceString(refNode, m_root, m_uri);
                        }
                        if (valueString == null)
                            valueString = attributeInfo.Type.Convert(value);

                        writer.WriteAttributeString(attributeInfo.Name, valueString);
                    }
                }
            }

            // write value if not the default
            if (valueAttribute != null)
            {
                object value = node.GetAttribute(valueAttribute);
                writer.WriteString(valueAttribute.Type.Convert(value));
            }

            // write child elements
            foreach (ChildInfo childInfo in type.Children)
            {
                if (childInfo.IsList)
                {
                    foreach (DomNode child in node.GetChildList(childInfo))
                        WriteElement(child, writer);
                }
                else
                {
                    DomNode child = node.GetChild(childInfo);
                    if (child != null)
                        WriteElement(child, writer);
                }
            }

            writer.WriteEndElement();
        }
Exemplo n.º 41
0
 public Prototype(DomNode node, Uri ur)
 {
     m_node = node;
     m_uri = ur;
     IGameObject gob = m_node.GetChild(Schema.prototypeType.gameObjectChild).As<IGameObject>();
     gob.Name = Type + "_" + Path.GetFileNameWithoutExtension(ur.LocalPath);
 }
Exemplo n.º 42
0
Arquivo: Tools.cs Projeto: Joxx0r/ATF
 /// <summary>
 /// Gets float value associated with DomNode</summary>
 /// <param name="domNode">DomNode whose value is obtained</param>
 /// <returns>Float value associated with DomNode</returns>
 public static float GetFloat(DomNode domNode)
 {
     float value = default(float);
     if (domNode != null)
     {
         DomNode floatChild = domNode.GetChild(Schema.common_float_or_param_type.floatChild);
         if (floatChild != null)
         {
             double v = (double)floatChild.GetAttribute(Schema.common_float_or_param_type_float.Attribute);
             value = (float)v;
         }                
     }
     return value;
 }
Exemplo n.º 43
0
        public void TestGetChildList()
        {
            DomNodeType type = new DomNodeType("type");
            ChildInfo childInfo = new ChildInfo("child", type, true);
            type.Define(childInfo);

            DomNode parent = new DomNode(type);
            IList<DomNode> list = parent.GetChildList(childInfo);
            Assert.NotNull(list);
            Assert.Throws<InvalidOperationException>(delegate { parent.GetChild(childInfo); });
            CollectionAssert.IsEmpty(list);
        }
Exemplo n.º 44
0
        private void WriteElement(DomNode node, XmlWriter writer)
        {
            // If writing the project settings file...
            if (!m_bWritingUserSettings)
            {
                // Don't save types that are not supposed to be saved
                if (s_lstExcludeDomNodeTypes.Contains(node.Type))
                    return;
            }

            var elementNs = m_typeCollection.TargetNamespace;
            var index = node.ChildInfo.Name.LastIndexOf(':');
            if (index >= 0)
                elementNs = node.ChildInfo.Name.Substring(0, index);

            string elementPrefix;

            // is this the root DomNode (the one passed Write, above)?
            if (node == m_root)
            {
                elementPrefix = m_typeCollection.GetPrefix(elementNs) ?? GeneratePrefix(elementNs);

                writer.WriteStartElement(elementPrefix, node.ChildInfo.Name, elementNs);

                // define the xsi namespace
                writer.WriteAttributeString("xmlns", "xsi", null, XmlSchema.InstanceNamespace);

                // define schema namespaces
                foreach (var name in m_typeCollection.Namespaces)
                {
                    if (string.Compare(name.Name, elementPrefix) != 0)
                        writer.WriteAttributeString("xmlns", name.Name, null, name.Namespace);
                }
            }
            else
            {
                // not the root, so all schema namespaces have been defined
                elementPrefix = writer.LookupPrefix(elementNs) ?? GeneratePrefix(elementNs);

                writer.WriteStartElement(elementPrefix, node.ChildInfo.Name, elementNs);
            }

            // write type name if this is a polymorphic type
            var type = node.Type;
            if (node.ChildInfo.Type != type)
            {
                var name = type.Name;
                index = name.LastIndexOf(':');
                if (index >= 0)
                {
                    var typeName = name.Substring(index + 1, type.Name.Length - index - 1);
                    var typeNs = name.Substring(0, index);
                    var typePrefix = writer.LookupPrefix(typeNs);
                    if (typePrefix == null)
                    {
                        typePrefix = GeneratePrefix(typeNs);
                        writer.WriteAttributeString("xmlns", typePrefix, null, typeNs);
                    }

                    name = typeName;
                    if (typePrefix != string.Empty)
                        name = typePrefix + ":" + typeName;
                }

                writer.WriteAttributeString("xsi", "type", XmlSchema.InstanceNamespace, name);
            }

            // write attributes
            AttributeInfo valueAttribute = null;
            foreach (var attributeInfo in type.Attributes)
            {
                // if attribute is required, or not the default, write it
                if (/*attributeInfo.Required ||*/ !node.IsAttributeDefault(attributeInfo))
                {
                    if (attributeInfo.Name == string.Empty)
                    {
                        valueAttribute = attributeInfo;
                    }
                    else
                    {
                        var value = node.GetAttribute(attributeInfo);
                        string valueString = null;
                        if (attributeInfo.Type.Type == AttributeTypes.Reference)
                        {
                            // if reference is a valid node, convert to string
                            var refNode = value as DomNode;
                            if (refNode != null)
                                valueString = GetNodeReferenceString(refNode, m_root);
                        }
                        if (valueString == null)
                            valueString = attributeInfo.Type.Convert(value);

                        var bWriteAttribute = true;
                        if (!m_bWritingUserSettings)
                            bWriteAttribute = !s_lstExcludeAttributes.Contains(attributeInfo.Name);

                        if (bWriteAttribute)
                            writer.WriteAttributeString(attributeInfo.Name, valueString);
                    }
                }
            }

            // write value if not the default
            if (valueAttribute != null)
            {
                var value = node.GetAttribute(valueAttribute);
                writer.WriteString(valueAttribute.Type.Convert(value));
            }

            // write child elements
            foreach (var childInfo in type.Children)
            {
                if (childInfo.IsList)
                {
                    foreach (var child in node.GetChildList(childInfo))
                        WriteElement(child, writer);
                }
                else
                {
                    var child = node.GetChild(childInfo);
                    if (child != null)
                        WriteElement(child, writer);
                }
            }

            writer.WriteEndElement();
        }
Exemplo n.º 45
0
        public void TestAddChildAndModifyInTransaction()
        {
            DomNode child = m_root.GetChild(ChildInfo);
            DomNode grandchild = child.GetChild(ChildInfo);
            var greatGrandchild = new DomNode(ChildType, ChildInfo);

            // Add a great-grandchild and then modify it. The attribute changed events should be ignored.
            m_transactionContext.DoTransaction(() =>
            {
                grandchild.SetChild(ChildInfo, greatGrandchild);
                greatGrandchild.SetAttribute(StringAttrInfo, "foo1");
            }, "test transaction 1");

            Assert.IsTrue(m_events.Count == 1);
            CheckChildInsertedEvent(m_events[0], grandchild, greatGrandchild);

            // Make sure the TransactionReporter's state gets cleared for the next transaction.
            m_events.Clear();
            m_transactionContext.DoTransaction(() =>
            {
                grandchild.SetChild(ChildInfo, null);//remove great-grandchild
                greatGrandchild.SetChild(ChildInfo, new DomNode(ChildType));
                grandchild.SetChild(ChildInfo, greatGrandchild);//insert great-grandchild (and its child)
                greatGrandchild.SetAttribute(StringAttrInfo, "foo2");
                greatGrandchild.GetChild(ChildInfo).SetAttribute(StringAttrInfo, "child foo2");
            }, "test transaction 2");
            Assert.IsTrue(m_events.Count == 2);
            CheckChildRemovedEvent(m_events[0], grandchild, greatGrandchild);
            CheckChildInsertedEvent(m_events[1], grandchild, greatGrandchild);

            // This time, make sure that removing the child of a newly inserted tree doesn't generate new events.
            greatGrandchild.RemoveFromParent();
            var great2Grandchild = new DomNode(ChildType);
            greatGrandchild.SetChild(ChildInfo, great2Grandchild);
            m_events.Clear();
            m_transactionContext.DoTransaction(() =>
            {
                grandchild.SetChild(ChildInfo, greatGrandchild);//insert great-grandchild and great2Grandchild
                greatGrandchild.SetAttribute(StringAttrInfo, "foo3");
                great2Grandchild.SetAttribute(StringAttrInfo, "foo3");
                great2Grandchild.RemoveFromParent();
            }, "test transaction 3");
            Assert.IsTrue(m_events.Count == 1);
            CheckChildInsertedEvent(m_events[0], grandchild, greatGrandchild);

            // This time, make sure that removing two children of a newly inserted tree doesn't generate new events.
            grandchild.SetChild(ChildInfo, null);
            greatGrandchild.SetChild(ChildInfo, great2Grandchild);
            var great3Grandchild = new DomNode(ChildType);
            great2Grandchild.SetChild(ChildInfo, great3Grandchild);
            m_events.Clear();
            m_transactionContext.DoTransaction(() =>
            {
                grandchild.SetChild(ChildInfo, greatGrandchild);
                greatGrandchild.SetAttribute(StringAttrInfo, "foo4");
                great2Grandchild.SetAttribute(StringAttrInfo, "foo4");
                great3Grandchild.SetAttribute(StringAttrInfo, "foo4");
                great3Grandchild.RemoveFromParent();
                great2Grandchild.RemoveFromParent();
            }, "test transaction 4");
            Assert.IsTrue(m_events.Count == 1);
            CheckChildInsertedEvent(m_events[0], grandchild, greatGrandchild);

            // Check that removing all the inserted children generates no events.
            grandchild.SetChild(ChildInfo, null);
            greatGrandchild.SetChild(ChildInfo, great2Grandchild);
            great2Grandchild.SetChild(ChildInfo, great3Grandchild);
            m_events.Clear();
            m_transactionContext.DoTransaction(() =>
            {
                grandchild.SetChild(ChildInfo, greatGrandchild);
                greatGrandchild.SetAttribute(StringAttrInfo, "foo5");
                great2Grandchild.SetAttribute(StringAttrInfo, "foo5");
                great3Grandchild.SetAttribute(StringAttrInfo, "foo5");
                great3Grandchild.RemoveFromParent();
                great2Grandchild.RemoveFromParent();
                greatGrandchild.RemoveFromParent();
            }, "test transaction 5");
            Assert.IsTrue(m_events.Count == 0);
        }