當前位置: 首頁>>代碼示例>>C#>>正文


C# XmlNode.AppendChildIfNotNull方法代碼示例

本文整理匯總了C#中System.Xml.XmlNode.AppendChildIfNotNull方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlNode.AppendChildIfNotNull方法的具體用法?C# XmlNode.AppendChildIfNotNull怎麽用?C# XmlNode.AppendChildIfNotNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.XmlNode的用法示例。


在下文中一共展示了XmlNode.AppendChildIfNotNull方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: WriteCompositeBoneProperty

 private static void WriteCompositeBoneProperty(XmlNode _node, CompositeBone bone, XmlDocument doc)
 {
     _node.AppendChildIfNotNull(WriteProperty("Name", bone, doc));
     _node.AppendChildIfNotNull(WriteProperty("SceneItem", bone, doc));
     _node.AppendChildIfNotNull(WriteProperty("SubItem", bone, doc));
     _node.AppendChildIfNotNull(WriteProperty("MasterVisibility", bone, doc));
     _node.AppendChildIfNotNull(WriteProperty("InheritPosition", bone, doc));
     _node.AppendChildIfNotNull(WriteProperty("InheritScale", bone, doc));
     _node.AppendChildIfNotNull(WriteProperty("InheritRotation", bone, doc));
     _node.AppendChildIfNotNull(WriteProperty("InheritVisibility", bone, doc));
     _node.AppendChildIfNotNull(WriteProperty("Interpolate", bone, doc));
     XmlNode childBonesNode = _node.AppendChild(doc.CreateElement("ChildBones"));            
     foreach (var childBone in bone.ChildBones)
     {
         XmlNode childNode = childBonesNode.AppendChild(doc.CreateElement("Bone"));
         WriteCompositeBoneProperty(childNode, childBone, doc);
     }
 }
開發者ID:dekk7,項目名稱:xEngine,代碼行數:18,代碼來源:SceneSerializer.cs

示例2: WriteIAnimationDirectorProperties

 private static void WriteIAnimationDirectorProperties(XmlDocument _doc, XmlNode itemNode,
     IAnimationDirector director)
 {
     itemNode.AppendChildIfNotNull(WriteProperty("AutoPlay", director, _doc));
     itemNode.AppendChildIfNotNull(WriteProperty("DefaultAnimation", director, _doc));
 }
開發者ID:dekk7,項目名稱:xEngine,代碼行數:6,代碼來源:SceneSerializer.cs

示例3: WriteIAnimationProperties

 private static void WriteIAnimationProperties(XmlDocument _doc, XmlNode itemNode, IAnimation animation)
 {
     itemNode.AppendChildIfNotNull(WriteProperty("LoopMax", animation, _doc));
     itemNode.AppendChildIfNotNull(WriteProperty("Life", animation, _doc));
     itemNode.AppendChildIfNotNull(WriteProperty("AutoPlay", animation, _doc));
     itemNode.AppendChildIfNotNull(WriteProperty("HideWhenStopped", animation, _doc));            
 }
開發者ID:dekk7,項目名稱:xEngine,代碼行數:7,代碼來源:SceneSerializer.cs

示例4: WriteSpriteItemBase

 private static void WriteSpriteItemBase(XmlNode itemNode, XmlDocument doc, Sprite item)
 {
     itemNode.Attributes.Append(doc.CreateAttribute("materialSource")).InnerText = GetAssetSource(item.Material);
     itemNode.Attributes.Append(doc.CreateAttribute("materialRef")).InnerText = item.Material.Name;
     if (String.IsNullOrEmpty(item.MaterialArea) == false)
     {
         itemNode.Attributes.Append(doc.CreateAttribute("materialArea")).InnerText = item.MaterialArea;
     }
     else if (item.SourceRectangle != null)
     {
         itemNode.AppendChildIfNotNull(WriteProperty("SourceRectangle", item, doc));
     }
     itemNode.AppendChildIfNotNull(WriteProperty("Tint", item, doc));
     itemNode.AppendChildIfNotNull(WriteProperty("BlendingType", item, doc));
     itemNode.AppendChildIfNotNull(WriteProperty("UseTilingSafeBorders", item, doc));
 }
開發者ID:dekk7,項目名稱:xEngine,代碼行數:16,代碼來源:SceneSerializer.cs

示例5: WriteSceneItemBase

 private static void WriteSceneItemBase(XmlNode node, XmlDocument doc, SceneItem item)
 {
     node.Attributes.Append(doc.CreateAttribute("name")).InnerText = item.Name;
     node.AppendChildIfNotNull(WriteProperty("Position", item, doc));
     node.AppendChildIfNotNull(WriteProperty("Pivot", item, doc));
     node.AppendChildIfNotNull(WriteProperty("IsPivotRelative", item, doc));
     node.AppendChildIfNotNull(WriteProperty("IgnoreCameraPosition", item, doc));
     node.AppendChildIfNotNull(WriteProperty("Rotation", item, doc));
     node.AppendChildIfNotNull(WriteProperty("Scale", item, doc));
     node.AppendChildIfNotNull(WriteProperty("Opacity", item, doc));
     node.AppendChildIfNotNull(WriteProperty("IsTemplate", item, doc));
     node.AppendChildIfNotNull(WriteProperty("Layer", item, doc));
     node.AppendChildIfNotNull(WriteProperty("Visible", item, doc));
     node.AppendChildIfNotNull(WriteProperty("FlipHorizontal", item, doc));
     node.AppendChildIfNotNull(WriteProperty("FlipVertical", item, doc));
 }
開發者ID:dekk7,項目名稱:xEngine,代碼行數:16,代碼來源:SceneSerializer.cs

示例6: WriteParticleEffect

        private static void WriteParticleEffect(XmlNode itemNode, XmlDocument doc, ParticleEffect particleEffect)
        {

            itemNode.AppendChildIfNotNull(WriteProperty("EditorBackgroundColor", particleEffect, doc));
            WriteIAnimationProperties(doc, itemNode, particleEffect);
            //XmlNode _emitternode=itemNode.AppendChild(_doc.CreateElement("Emitter"));
            try
            {

                XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
                ns.Add("", "");

                MemoryStream ms = new MemoryStream();
                XmlSerializer ser = new XmlSerializer(typeof(Emitter), "");
                XmlWriterSettings sett = new XmlWriterSettings();
                sett.OmitXmlDeclaration = true;
                sett.Indent = true;
                XmlWriter writer = XmlTextWriter.Create(ms, sett);
                ser.Serialize(writer, particleEffect.Emitter, ns);
                ms.Flush();
                ms.Position = 0;

                XmlDocument doc1 = new XmlDocument();
                doc1.Load(ms);

                XmlNode newNode = doc.ImportNode(doc1.SelectSingleNode("Emitter"), true);

                int i = 0;
                XmlNode _node = newNode.SelectSingleNode("ParticleTypes");
                foreach (XmlNode _child in _node.ChildNodes)
                {
                    ParticleType _type = particleEffect.Emitter.ParticleTypes[i];
                    XmlNode _mat = WriteProperty("Material", _type, doc);
                    _mat.Attributes.Append(doc.CreateAttribute("materialSource")).InnerText = GetAssetSource(_type.Material);

                    _child.AppendChildIfNotNull(_mat);
                    //_node.AppendChild(_child);
                    i++;
                }

                itemNode.AppendChildIfNotNull(newNode);
                ms.Close();

            }
            catch (Exception er)
            {
                Console.WriteLine(er.ToString());
                throw er;
            }
        }
開發者ID:dekk7,項目名稱:xEngine,代碼行數:50,代碼來源:SceneSerializer.cs

示例7: WriteTextItem

 private static void WriteTextItem(XmlNode itemNode, XmlDocument doc, TextItem text)
 {
     string _source = GetAssetSource(text.Font);
     itemNode.Attributes.Append(doc.CreateAttribute("fontSource")).InnerText = _source;
     itemNode.Attributes.Append(doc.CreateAttribute("fontRef")).InnerText = text.Font.Name;
     itemNode.AppendChildIfNotNull(WriteProperty("Text", text, doc));
     itemNode.AppendChildIfNotNull(WriteProperty("AutoCenterPivot", text, doc));
     itemNode.AppendChildIfNotNull(WriteProperty("Scale", text, doc));
     itemNode.AppendChildIfNotNull(WriteProperty("Tint", text, doc));
     itemNode.AppendChildIfNotNull(WriteProperty("Shadow", text, doc));
 }
開發者ID:dekk7,項目名稱:xEngine,代碼行數:11,代碼來源:SceneSerializer.cs

示例8: WriteSceneItem

        private static XmlNode WriteSceneItem(XmlDocument doc, XmlNode rootnode, XmlNode _itemNode, SceneItem item)
        {
            //PrintPropertiesOfType(_sceneItemType, "-");
            _itemNode = null;

            if (item is AnimatedSprite)
            {
                _itemNode = doc.CreateElement(NodeNames.ANIMATEDSPRITE);
                WriteSceneItemBase(_itemNode, doc, item);
                WriteSpriteItemBase(_itemNode, doc, (Sprite)item);
                WriteAnimatedSpriteItemBase(_itemNode, doc, (AnimatedSprite)item);
            }
            else if (item is ParticleEffect)
            {
                _itemNode = doc.CreateElement(NodeNames.PARTICLEEFFECT);

                WriteParticleEffect(_itemNode, doc, (ParticleEffect)item);
                WriteSceneItemBase(_itemNode, doc, item);
            }
            else if (item is PostProcessAnimation)
            {
                _itemNode = doc.CreateElement(NodeNames.POSTPROCESSANIMATION);

                WriteSceneItemBase(_itemNode, doc, item);
                WritePostProcess(_itemNode, doc, item);
            }            
            else if (item is TileGrid)
            {
                _itemNode = doc.CreateElement(NodeNames.TILEGRID);
                WriteSceneItemBase(_itemNode, doc, item);
                WriteSpriteItemBase(_itemNode, doc, (Sprite)item);
                WriteTileGrid(_itemNode, doc, (TileGrid)item);
            }
            else if (item is CompositeEntity)
            {
                _itemNode = doc.CreateElement(NodeNames.COMPOSITEENTITY);
                WriteSceneItemBase(_itemNode, doc, item);
                WriteCompositeEntity(_itemNode, doc, (CompositeEntity)item);
            }
            else if (item is Sprite)
            {
                _itemNode = doc.CreateElement(NodeNames.SPRITE);
                WriteSceneItemBase(_itemNode, doc, item);
                WriteSpriteItemBase(_itemNode, doc, (Sprite)item);
            }
            else if (item is TextItem)
            {
                _itemNode = doc.CreateElement(NodeNames.TEXTITEM);
                WriteSceneItemBase(_itemNode, doc, item);
                WriteTextItem(_itemNode, doc, (TextItem)item);
            }
            else
            {
                _itemNode = doc.CreateElement(NodeNames.SCENEITEM);
                WriteSceneItemBase(_itemNode, doc, item);
            }

            _itemNode.AppendChildIfNotNull(WriteSceneItemComponents(doc, item));
            _itemNode.AppendChildIfNotNull(WriteSceneItemLinkPoints(doc, item));
            _itemNode.AppendChildIfNotNull(WriteSceneItemMounts(doc, item));
            rootnode.AppendChildIfNotNull(_itemNode);
            return _itemNode;
        }
開發者ID:dekk7,項目名稱:xEngine,代碼行數:63,代碼來源:SceneSerializer.cs

示例9: WriteSceneComponent

 private static void WriteSceneComponent(XmlNode sceneComponent, IceComponent comp, XmlDocument doc)
 {
     foreach (var _property in comp.GetType().GetProperties())
     {
         if (_property.GetCustomAttributes(typeof(IceCream.Attributes.IceComponentPropertyAttribute), true).Length > 0)
         {
             sceneComponent.AppendChildIfNotNull(WriteProperty(_property.Name, comp, doc));
         }
     }
 }
開發者ID:dekk7,項目名稱:xEngine,代碼行數:10,代碼來源:SceneSerializer.cs

示例10: WriteTileSheet

 private static void WriteTileSheet(XmlNode itemNode, XmlDocument doc, TileSheet tileSheet)
 {
     itemNode.Attributes.Append(doc.CreateAttribute("materialSource")).InnerText = GetAssetSource(tileSheet.Material);
     itemNode.Attributes.Append(doc.CreateAttribute("materialRef")).InnerText = tileSheet.Material.Name;
     SerializeAsset(doc, itemNode, tileSheet);
     itemNode.AppendChildIfNotNull(WriteProperty("TileSize", tileSheet, doc));
     itemNode.AppendChildIfNotNull(WriteProperty("EnableCollisionByDefault", tileSheet, doc));
     itemNode.AppendChildIfNotNull(WriteProperty("UseTilingSafeBorders", tileSheet, doc));
     XmlNode _polys = itemNode.AppendChild(doc.CreateElement("Polygons"));
     foreach (Polygon polygon in tileSheet.Polygons)
     {
         XmlNode _poly = _polys.AppendChild(doc.CreateElement("Polygon"));
         if (polygon == null)
         {
             _poly.InnerText = "n";
         }
         else
         {
             _poly.InnerText = polygon.ToString();
         }
     }
 }
開發者ID:dekk7,項目名稱:xEngine,代碼行數:22,代碼來源:SceneSerializer.cs


注:本文中的System.Xml.XmlNode.AppendChildIfNotNull方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。