Пример #1
0
        /// <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();
        }
Пример #2
0
        /// <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();
        }
Пример #3
0
        /// <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);
                        }
                    }
                }
            }
        }
Пример #4
0
 /// <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);
         }
     }
 }
Пример #5
0
        /// <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();
        }
Пример #6
0
        /// <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();
        }
Пример #7
0
        /// <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);
            }
        }
Пример #8
0
        /// <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);
                }
            }
        }
Пример #9
0
        /// <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();
        }
Пример #10
0
        /// <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();
        }
Пример #11
0
        /// <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);
            }
        }
Пример #12
0
        /// <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);
                        }
                    }
                }
            }
        }