本文整理汇总了C#中System.Xml.XmlWriter.?.WriteStartElement方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriter.?.WriteStartElement方法的具体用法?C# XmlWriter.?.WriteStartElement怎么用?C# XmlWriter.?.WriteStartElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlWriter
的用法示例。
在下文中一共展示了XmlWriter.?.WriteStartElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SerializeToXmlElement
protected internal virtual bool SerializeToXmlElement(XmlWriter writer, string elementName)
{
if ((_configRecord != null) && (_configRecord.TargetFramework != null))
{
ConfigurationSection section = null;
if (_configRecord.SectionsStack.Count > 0)
section = _configRecord.SectionsStack.Peek() as ConfigurationSection;
if ((section != null) &&
!section.ShouldSerializeElementInTargetVersion(this, elementName, _configRecord.TargetFramework))
return false;
}
bool dataToWrite = DataToWriteInternal;
// Don't write elements that are locked in the parent
if (((_lockedElementsList != null) && _lockedElementsList.DefinedInParent(elementName)) ||
((_lockedAllExceptElementsList != null) && _lockedAllExceptElementsList.HasParentElements &&
!_lockedAllExceptElementsList.DefinedInParent(elementName)))
return dataToWrite;
if (SerializeElement(null, false)) // check if there is anything to write...
{
writer?.WriteStartElement(elementName);
dataToWrite |= SerializeElement(writer, false);
writer?.WriteEndElement();
}
return dataToWrite;
}
示例2: SerializeElement
protected internal override bool SerializeElement(XmlWriter writer, bool serializeCollectionKey)
{
ConfigurationElementCollectionType type = CollectionType;
bool dataToWrite = false;
dataToWrite |= base.SerializeElement(writer, serializeCollectionKey);
if ((type == ConfigurationElementCollectionType.AddRemoveClearMap) ||
(type == ConfigurationElementCollectionType.AddRemoveClearMapAlternate))
{
// it is possible that the collection only has to be cleared and contains
// no real elements
if (_emitClearTag && (_clearElement.Length != 0))
{
if (writer != null)
{
writer.WriteStartElement(_clearElement);
writer.WriteEndElement();
}
dataToWrite = true;
}
}
foreach (Entry entry in Items)
switch (type)
{
case ConfigurationElementCollectionType.BasicMap:
case ConfigurationElementCollectionType.BasicMapAlternate:
if ((entry.EntryType == EntryType.Added) || (entry.EntryType == EntryType.Replaced))
{
if (!string.IsNullOrEmpty(ElementName))
{
if (BaseConfigurationRecord.IsReservedAttributeName(ElementName))
{
throw new ArgumentException(string.Format(SR.Basicmap_item_name_reserved,
ElementName));
}
dataToWrite |= entry.Value.SerializeToXmlElement(writer, ElementName);
}
else dataToWrite |= entry.Value.SerializeElement(writer, false);
}
break;
case ConfigurationElementCollectionType.AddRemoveClearMap:
case ConfigurationElementCollectionType.AddRemoveClearMapAlternate:
if (((entry.EntryType == EntryType.Removed) ||
(entry.EntryType == EntryType.Replaced)) &&
(entry.Value != null))
{
writer?.WriteStartElement(_removeElement);
entry.Value.SerializeElement(writer, true);
writer?.WriteEndElement();
dataToWrite = true;
}
if ((entry.EntryType == EntryType.Added) || (entry.EntryType == EntryType.Replaced))
dataToWrite |= entry.Value.SerializeToXmlElement(writer, _addElement);
break;
}
return dataToWrite;
}