using System.Collections; using Cobilas.Collections; using System.Collections.Generic; namespace System.Xml { /// /// Represents an XML element of type ProcessingInstruction. /// public class XMLIRWProcessingInstruction : XMLIRW, ITextValue, IEnumerable, IDisposable { private bool disposedValue; /// public XMLIRWText Text { get; set; } /// [Obsolete("Use the Text property.")] public XMLIRWValue Value { get; set; } /// public override XmlNodeType Type { get; set; } /// public override XMLIRW Parent { get; set; } = default; /// public override string Name { get; set; } = string.Empty; /// Checks whether the value is a list of attributes. public bool IsAttributeList => Text.Value is XMLIRWAttribute[]; /// Returns the number of attributes in the list. public int AttributeCount => ArrayManipulation.ArrayLength(IsAttributeList ? Text.Value as XMLIRWAttribute[] : new XMLIRWAttribute[0]); /// [Obsolete("Use the XMLIRWProcessingInstruction(XMLIRW, string, object) constructor.")] public XMLIRWProcessingInstruction(XMLIRW parent, string name, XMLIRWValue value) {} /// [Obsolete("Use the XMLIRWProcessingInstruction(string, object) constructor.")] public XMLIRWProcessingInstruction(string name, XMLIRWValue value) {} /// public XMLIRWProcessingInstruction(XMLIRW parent, string name, object value) : base(parent, name, XmlNodeType.ProcessingInstruction) { Text = new XMLIRWText(value); } /// public XMLIRWProcessingInstruction(string name, object value) : this((XMLIRW)null, name, value) {} /// public XMLIRWProcessingInstruction(XMLIRW parent, string name, XMLIRWAttribute[] attributes) : this(parent, name, (object)attributes) {} /// public XMLIRWProcessingInstruction(string name, XMLIRWAttribute[] attributes) : this(default, name, attributes) {} /// Called when the object is finished. ~XMLIRWProcessingInstruction() => Dispose(disposing: false); /// public override void Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } /// public IEnumerator GetEnumerator() => new ArrayToIEnumerator(IsAttributeList ? (XMLIRWAttribute[])Text.Value : new XMLIRWAttribute[0]); /// protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { Name = string.Empty; Parent = default; Type = default; Text = default; } disposedValue = true; } } IEnumerator IEnumerable.GetEnumerator() => new ArrayToIEnumerator(IsAttributeList ? (XMLIRWAttribute[])Text.Value : new XMLIRWAttribute[0]); } }