本文整理汇总了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);
}
}
示例2: WriteIAnimationDirectorProperties
private static void WriteIAnimationDirectorProperties(XmlDocument _doc, XmlNode itemNode,
IAnimationDirector director)
{
itemNode.AppendChildIfNotNull(WriteProperty("AutoPlay", director, _doc));
itemNode.AppendChildIfNotNull(WriteProperty("DefaultAnimation", director, _doc));
}
示例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));
}
示例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));
}
示例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));
}
示例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;
}
}
示例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));
}
示例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;
}
示例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));
}
}
}
示例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();
}
}
}