/// <summary> /// Creates a Text block with the text supplied. /// </summary> /// <param name="content"> /// The content to place in the CDATA block. /// </param> /// <returns> /// Always true. /// </returns> private bool TextInvokeMember(string content) { // Determine if we are at the root level and if we are trying to // create more than one node. if (this.CurrentAncestorNode == this.document && this.document.Items.Count != 0) { throw new InvalidOperationException("Text nodes can not be part of the root xml structure."); } DynaXmlText text = new DynaXmlText() { Value = content }; this.CurrentAncestorNode.Items.Add(text); return true; }
/// <summary> /// Adds an element with content to the tree. /// </summary> /// <param name="name"> /// The name of the element to add. /// </param> /// <param name="value"> /// The value to place as the text of the element. /// </param> /// <returns> /// Always true. /// </returns> private bool ElementBuilderInvokeMember(string name, string value) { // Determine if we are at the root level and if we are trying to // create more than one node. if (this.CurrentAncestorNode == this.document && this.document.Items.Count != 0) { throw new InvalidOperationException("An Xml Document may not have more than one root element."); } DynaXmlElement element = this.CreateElement(name); DynaXmlText text = new DynaXmlText() { Value = value }; element.Items.Add(text); this.CurrentAncestorNode.Items.Add(element); if (this.State == DynaXmlBuilderState.LiteralElementBuilder) { this.context.Pop(); } return true; }