/// <summary> /// Asynchronously writes the <see cref="SpecType"/>s /// </summary> /// <param name="writer"> /// an instance of <see cref="XmlWriter"/> /// </param> /// <param name="token"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> private async Task WriteSpecTypesAsync(XmlWriter writer, CancellationToken token) { if (token.IsCancellationRequested) { token.ThrowIfCancellationRequested(); } if (this.specTypes.Count == 0) { return; } await writer.WriteStartElementAsync(null, "SPEC-TYPES", null); foreach (var specType in this.specTypes) { var xmlElementNAme = ReqIfFactory.XmlName(specType); await writer.WriteStartElementAsync(null, xmlElementNAme, null); await specType.WriteXmlAsync(writer, token); await writer.WriteEndElementAsync(); } await writer.WriteEndElementAsync(); }
/// <summary> /// Asynchronously writes the <see cref="DatatypeDefinition"/>s /// </summary> /// <param name="writer"> /// an instance of <see cref="XmlWriter"/> /// </param> /// <param name="token"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> private async Task WriteDataDefinitionsAsync(XmlWriter writer, CancellationToken token) { if (token.IsCancellationRequested) { token.ThrowIfCancellationRequested(); } if (this.dataTypes.Count == 0) { return; } await writer.WriteStartElementAsync(null, "DATATYPES", null); foreach (var datatypeDefinition in this.dataTypes) { var xmlElementNAme = ReqIfFactory.XmlName(datatypeDefinition); await writer.WriteStartElementAsync(null, xmlElementNAme, null); await datatypeDefinition.WriteXmlAsync(writer, token); await writer.WriteEndElementAsync(); } await writer.WriteEndElementAsync(); }
/// <summary> /// Asynchronously deserialize the <see cref="SpecType"/>s contained by the <code>SPEC-TYPES</code> element. /// </summary> /// <param name="reader"> /// an instance of <see cref="XmlReader"/> /// </param> /// <param name="token"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> private async Task DeserializeSpecTypesAsync(XmlReader reader, CancellationToken token) { while (await reader.ReadAsync()) { if (token.IsCancellationRequested) { token.ThrowIfCancellationRequested(); } if (await reader.MoveToContentAsync() == XmlNodeType.Element) { var xmlname = reader.LocalName; if (xmlname == "SPEC-OBJECT-TYPE" || xmlname == "SPECIFICATION-TYPE" || xmlname == "SPEC-RELATION-TYPE" || xmlname == "RELATION-GROUP-TYPE") { using (var subtree = reader.ReadSubtree()) { await subtree.MoveToContentAsync(); var specType = ReqIfFactory.SpecTypeConstruct(xmlname, this, this.loggerFactory); await specType.ReadXmlAsync(subtree, token); } } } } }
/// <summary> /// Deserialize the <see cref="DatatypeDefinition"/>s contained by the <code>DATATYPES</code> element. /// </summary> /// <param name="reader"> /// an instance of <see cref="XmlReader"/> /// </param> private void DeserializeDataTypes(XmlReader reader) { while (reader.Read()) { if (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName.StartsWith("DATATYPE-DEFINITION-")) { var datatypeDefinition = ReqIfFactory.DatatypeDefinitionConstruct(reader.LocalName, this); datatypeDefinition.ReadXml(reader); } } }
/// <summary> /// Write the <see cref="SpecType"/>s /// </summary> /// <param name="writer"> /// an instance of <see cref="XmlWriter"/> /// </param> private void WriteSpecTypes(XmlWriter writer) { writer.WriteStartElement("SPEC-TYPES"); foreach (var specType in this.specTypes) { var xmlElementNAme = ReqIfFactory.XmlName(specType); writer.WriteStartElement(xmlElementNAme); specType.WriteXml(writer); writer.WriteEndElement(); } writer.WriteEndElement(); }
/// <summary> /// Write the <see cref="DatatypeDefinition"/>s /// </summary> /// <param name="writer"> /// an instance of <see cref="XmlWriter"/> /// </param> private void WriteDataDefinitions(XmlWriter writer) { writer.WriteStartElement("DATATYPES"); foreach (var datatypeDefinition in this.dataTypes) { var xmlElementNAme = ReqIfFactory.XmlName(datatypeDefinition); writer.WriteStartElement(xmlElementNAme); datatypeDefinition.WriteXml(writer); writer.WriteEndElement(); } writer.WriteEndElement(); }
/// <summary> /// Creates <see cref="AttributeDefinition"/> and adds it to the <see cref="SpecAttributes"/> list. /// </summary> /// <param name="reader"> /// an instance of <see cref="XmlReader"/> /// </param> /// <param name="xmlname"> /// The XML Element name of the <see cref="AttributeDefinition"/> /// </param> private void CreateAttributeDefinition(XmlReader reader, string xmlname) { var attributeDefinition = ReqIfFactory.AttributeDefinitionConstruct(xmlname, this); if (attributeDefinition == null) { return; } using (var attributeDefTree = reader.ReadSubtree()) { attributeDefTree.MoveToContent(); attributeDefinition.ReadXml(attributeDefTree); } }
/// <summary> /// Asynchronously deserialize the <see cref="DatatypeDefinition"/>s contained by the <code>DATATYPES</code> element. /// </summary> /// <param name="reader"> /// an instance of <see cref="XmlReader"/> /// </param> /// <param name="token"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> private async Task DeserializeDataTypesAsync(XmlReader reader, CancellationToken token) { while (await reader.ReadAsync()) { if (token.IsCancellationRequested) { token.ThrowIfCancellationRequested(); } if (await reader.MoveToContentAsync() == XmlNodeType.Element && reader.LocalName.StartsWith("DATATYPE-DEFINITION-")) { var datatypeDefinition = ReqIfFactory.DatatypeDefinitionConstruct(reader.LocalName, this, this.loggerFactory); await datatypeDefinition.ReadXmlAsync(reader, token); } } }
/// <summary> /// Writes the <see cref="AttributeDefinition"/> objects from the <see cref="SpecAttributes"/> list. /// </summary> /// <param name="writer"> /// an instance of <see cref="XmlWriter"/> /// </param> private void WriteSpecAttributes(XmlWriter writer) { if (this.specAttributes.Count == 0) { return; } writer.WriteStartElement("SPEC-ATTRIBUTES"); foreach (var attributeDefinition in this.specAttributes) { var xmlname = ReqIfFactory.XmlName(attributeDefinition); writer.WriteStartElement(xmlname); attributeDefinition.WriteXml(writer); writer.WriteEndElement(); } writer.WriteEndElement(); }
/// <summary> /// Asynchronously writes the <see cref="AttributeDefinition"/> objects from the <see cref="SpecAttributes"/> list. /// </summary> /// <param name="writer"> /// an instance of <see cref="XmlWriter"/> /// </param> /// <param name="token"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> private async Task WriteSpecAttributesAsync(XmlWriter writer, CancellationToken token) { if (this.specAttributes.Count == 0) { return; } await writer.WriteStartElementAsync(null, "SPEC-ATTRIBUTES", null); foreach (var attributeDefinition in this.specAttributes) { var xmlname = ReqIfFactory.XmlName(attributeDefinition); await writer.WriteStartElementAsync(null, xmlname, null); await attributeDefinition.WriteXmlAsync(writer, token); await writer.WriteEndElementAsync(); } await writer.WriteEndElementAsync(); }
/// <summary> /// Asynchronously creates <see cref="AttributeDefinition"/> and adds it to the <see cref="SpecAttributes"/> list. /// </summary> /// <param name="reader"> /// an instance of <see cref="XmlReader"/> /// </param> /// <param name="xmlname"> /// The XML Element name of the <see cref="AttributeDefinition"/> /// </param> /// <param name="token"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> private async Task CreateAttributeDefinitionAsync(XmlReader reader, string xmlname, CancellationToken token) { var attributeDefinition = ReqIfFactory.AttributeDefinitionConstruct(xmlname, this, this.loggerFactory); if (attributeDefinition == null) { return; } if (token.IsCancellationRequested) { token.ThrowIfCancellationRequested(); } using (var attributeDefTree = reader.ReadSubtree()) { await attributeDefTree.MoveToContentAsync(); await attributeDefinition.ReadXmlAsync(attributeDefTree, token); } }
/// <summary> /// Deserialize the <see cref="SpecType"/>s contained by the <code>SPEC-TYPES</code> element. /// </summary> /// <param name="reader"> /// an instance of <see cref="XmlReader"/> /// </param> private void DeserializeSpecTypes(XmlReader reader) { while (reader.Read()) { if (reader.MoveToContent() == XmlNodeType.Element) { var xmlname = reader.LocalName; if (xmlname == "SPEC-OBJECT-TYPE" || xmlname == "SPECIFICATION-TYPE" || xmlname == "SPEC-RELATION-TYPE" || xmlname == "RELATION-GROUP-TYPE") { using (var subtree = reader.ReadSubtree()) { subtree.MoveToContent(); var specType = ReqIfFactory.SpecTypeConstrcut(xmlname, this); specType.ReadXml(subtree); } } } } }