예제 #1
0
        /// <summary>
        /// Generates a <see cref="AttributeDefinitionDate"/> object from its XML representation.
        /// </summary>
        /// <param name="reader">
        /// an instance of <see cref="XmlReader"/>
        /// </param>
        public override void ReadXml(XmlReader reader)
        {
            base.ReadXml(reader);

            while (reader.Read())
            {
                if (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "ALTERNATIVE-ID")
                {
                    var alternativeId = new AlternativeId(this);
                    alternativeId.ReadXml(reader);
                }

                // read the default value if any
                if (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "ATTRIBUTE-VALUE-DATE")
                {
                    this.DefaultValue = new AttributeValueDate(this);
                    using (var valuesubtree = reader.ReadSubtree())
                    {
                        valuesubtree.MoveToContent();
                        this.DefaultValue.ReadXml(valuesubtree);
                    }
                }

                if (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "DATATYPE-DEFINITION-DATE-REF")
                {
                    var reference = reader.ReadElementContentAsString();

                    var datatypeDefinition = (DatatypeDefinitionDate)this.SpecType.ReqIFContent.DataTypes.SingleOrDefault(x => x.Identifier == reference);
                    this.Type = datatypeDefinition;
                }
            }
        }
예제 #2
0
        /// <summary>
        /// Generates a <see cref="DatatypeDefinitionEnumeration"/> object from its XML representation.
        /// </summary>
        /// <param name="reader">
        /// an instance of <see cref="XmlReader"/>
        /// </param>
        internal override void ReadXml(XmlReader reader)
        {
            base.ReadXml(reader);

            using (var subtree = reader.ReadSubtree())
            {
                while (subtree.Read())
                {
                    if (subtree.MoveToContent() == XmlNodeType.Element)
                    {
                        switch (subtree.LocalName)
                        {
                        case "ALTERNATIVE-ID":
                            var alternativeId = new AlternativeId(this);
                            alternativeId.ReadXml(subtree);
                            break;

                        case "ENUM-VALUE":
                            var enumValue = new EnumValue(this, this.loggerFactory);
                            enumValue.ReadXml(subtree);
                            break;
                        }
                    }
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Asynchronously generates a <see cref="AttributeDefinitionEnumeration"/> object from its XML representation.
        /// </summary>
        /// <param name="reader">
        /// an instance of <see cref="XmlReader"/>
        /// </param>
        internal override async Task ReadXmlAsync(XmlReader reader, CancellationToken token)
        {
            base.ReadXml(reader);

            if (reader.GetAttribute("MULTI-VALUED") == "true")
            {
                this.IsMultiValued = true;
            }

            while (await reader.ReadAsync())
            {
                if (token.IsCancellationRequested)
                {
                    token.ThrowIfCancellationRequested();
                }

                if (await reader.MoveToContentAsync() == XmlNodeType.Element)
                {
                    switch (reader.LocalName)
                    {
                    case "ALTERNATIVE-ID":
                        var alternativeId = new AlternativeId(this);
                        alternativeId.ReadXml(reader);
                        break;

                    case "DATATYPE-DEFINITION-ENUMERATION-REF":
                        var reference = await reader.ReadElementContentAsStringAsync();

                        var datatypeDefinition = (DatatypeDefinitionEnumeration)this.SpecType.ReqIFContent.DataTypes.SingleOrDefault(x => x.Identifier == reference);
                        this.Type = datatypeDefinition;

                        if (datatypeDefinition == null)
                        {
                            this.logger.LogTrace("The DatatypeDefinitionEnumeration:{reference} could not be found and has been set to null on AttributeDefinitionEnumeration:{Identifier}", reference, Identifier);
                        }

                        break;

                    case "ATTRIBUTE-VALUE-ENUMERATION":
                        this.DefaultValue = new AttributeValueEnumeration(this, this.loggerFactory);
                        using (var valueSubtree = reader.ReadSubtree())
                        {
                            await valueSubtree.MoveToContentAsync();

                            await this.DefaultValue.ReadXmlAsync(valueSubtree, token);
                        }
                        break;
                    }
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Asynchronously generates a <see cref="SpecType"/> object from its XML representation.
        /// </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>
        internal async Task ReadXmlAsync(XmlReader reader, CancellationToken token)
        {
            base.ReadXml(reader);

            while (await reader.ReadAsync())
            {
                if (token.IsCancellationRequested)
                {
                    token.ThrowIfCancellationRequested();
                }

                if (await reader.MoveToContentAsync() == XmlNodeType.Element)
                {
                    switch (reader.LocalName)
                    {
                    case "ALTERNATIVE-ID":
                        using (var subtree = reader.ReadSubtree())
                        {
                            var alternativeId = new AlternativeId(this);
                            await subtree.MoveToContentAsync();

                            alternativeId.ReadXml(reader);
                        }

                        break;

                    case "SPEC-ATTRIBUTES":

                        using (var specAttributesSubTree = reader.ReadSubtree())
                        {
                            while (await specAttributesSubTree.ReadAsync())
                            {
                                if (token.IsCancellationRequested)
                                {
                                    token.ThrowIfCancellationRequested();
                                }

                                if (await reader.MoveToContentAsync() == XmlNodeType.Element && reader.LocalName.StartsWith("ATTRIBUTE-DEFINITION-"))
                                {
                                    await this.CreateAttributeDefinitionAsync(reader, reader.LocalName, token);
                                }
                            }
                        }

                        break;
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// Asynchronously generates a <see cref="SpecHierarchy"/> object from its XML representation.
        /// </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>
        internal async Task ReadXmlAsync(XmlReader reader, CancellationToken token)
        {
            base.ReadXml(reader);

            while (await reader.ReadAsync())
            {
                if (token.IsCancellationRequested)
                {
                    token.ThrowIfCancellationRequested();
                }

                if (await reader.MoveToContentAsync() == XmlNodeType.Element)
                {
                    switch (reader.LocalName)
                    {
                    case "ALTERNATIVE-ID":
                        using (var subtree = reader.ReadSubtree())
                        {
                            var alternativeId = new AlternativeId(this);
                            await subtree.MoveToContentAsync();

                            alternativeId.ReadXml(reader);
                        }
                        break;

                    case "OBJECT":
                        using (var subtree = reader.ReadSubtree())
                        {
                            await subtree.MoveToContentAsync();

                            await this.DeserializeObjectAsync(subtree, token);
                        }
                        break;

                    case "CHILDREN":
                        using (var subtree = reader.ReadSubtree())
                        {
                            await subtree.MoveToContentAsync();

                            await this.DeserializeSpecHierarchyAsync(subtree, token);
                        }
                        break;
                    }
                }
            }
        }
예제 #6
0
        /// <summary>
        /// Generates a <see cref="SpecHierarchy"/> object from its XML representation.
        /// </summary>
        /// <param name="reader">
        /// an instance of <see cref="XmlReader"/>
        /// </param>
        internal override void ReadXml(XmlReader reader)
        {
            base.ReadXml(reader);

            using (var speccHierarchySubtree = reader.ReadSubtree())
            {
                while (speccHierarchySubtree.Read())
                {
                    if (speccHierarchySubtree.MoveToContent() == XmlNodeType.Element)
                    {
                        switch (speccHierarchySubtree.LocalName)
                        {
                        case "ALTERNATIVE-ID":
                            using (var subtree = speccHierarchySubtree.ReadSubtree())
                            {
                                var alternativeId = new AlternativeId(this);
                                subtree.MoveToContent();
                                alternativeId.ReadXml(subtree);
                            }

                            break;

                        case "OBJECT":
                            using (var subtree = speccHierarchySubtree.ReadSubtree())
                            {
                                subtree.MoveToContent();
                                this.DeserializeObject(subtree);
                            }

                            break;

                        case "CHILDREN":
                            using (var subtree = speccHierarchySubtree.ReadSubtree())
                            {
                                subtree.MoveToContent();
                                this.DeserializeSpecHierarchy(subtree);
                            }

                            break;
                        }
                    }
                }
            }
        }
예제 #7
0
 /// <summary>
 /// Asynchronously read the <see cref="AlternativeId"/> from the <see cref="XmlReader"/>
 /// </summary>
 /// <param name="reader">
 /// The reader to read from
 /// </param>
 protected void ReadAlternativeId(XmlReader reader)
 {
     using (var subtree = reader.ReadSubtree())
     {
         while (subtree.Read())
         {
             if (subtree.MoveToContent() == XmlNodeType.Element)
             {
                 switch (subtree.LocalName)
                 {
                 case "ALTERNATIVE-ID":
                     var alternativeId = new AlternativeId(this);
                     alternativeId.ReadXml(subtree);
                     break;
                 }
             }
         }
     }
 }
        /// <summary>
        /// Generates a <see cref="AttributeDefinitionInteger"/> object from its XML representation.
        /// </summary>
        /// <param name="reader">
        /// an instance of <see cref="XmlReader"/>
        /// </param>
        internal override void ReadXml(XmlReader reader)
        {
            base.ReadXml(reader);

            while (reader.Read())
            {
                if (reader.MoveToContent() == XmlNodeType.Element)
                {
                    switch (reader.LocalName)
                    {
                    case "ALTERNATIVE-ID":
                        var alternativeId = new AlternativeId(this);
                        alternativeId.ReadXml(reader);
                        break;

                    case "DATATYPE-DEFINITION-INTEGER-REF":
                        var reference          = reader.ReadElementContentAsString();
                        var datatypeDefinition = (DatatypeDefinitionInteger)this.SpecType.ReqIFContent.DataTypes.SingleOrDefault(x => x.Identifier == reference);
                        this.Type = datatypeDefinition;

                        if (datatypeDefinition == null)
                        {
                            this.logger.LogTrace("The DatatypeDefinitionInteger:{reference} could not be found and has been set to null on AttributeDefinitionInteger:{Identifier}", reference, Identifier);
                        }

                        break;

                    case "ATTRIBUTE-VALUE-INTEGER":
                        this.DefaultValue = new AttributeValueInteger(this, this.loggerFactory);
                        using (var valueSubtree = reader.ReadSubtree())
                        {
                            valueSubtree.MoveToContent();
                            this.DefaultValue.ReadXml(valueSubtree);
                        }
                        break;
                    }
                }
            }
        }
예제 #9
0
        /// <summary>
        /// Generates a <see cref="SpecType"/> object from its XML representation.
        /// </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>
        internal override void ReadXml(XmlReader reader)
        {
            base.ReadXml(reader);

            while (reader.Read())
            {
                if (reader.MoveToContent() == XmlNodeType.Element)
                {
                    switch (reader.LocalName)
                    {
                    case "ALTERNATIVE-ID":
                        using (var subtree = reader.ReadSubtree())
                        {
                            var alternativeId = new AlternativeId(this);
                            subtree.MoveToContent();
                            alternativeId.ReadXml(subtree);
                        }

                        break;

                    case "SPEC-ATTRIBUTES":

                        using (var specAttributesSubTree = reader.ReadSubtree())
                        {
                            while (specAttributesSubTree.Read())
                            {
                                if (reader.MoveToContent() == XmlNodeType.Element && reader.LocalName.StartsWith("ATTRIBUTE-DEFINITION-"))
                                {
                                    this.CreateAttributeDefinition(reader, reader.LocalName);
                                }
                            }
                        }

                        break;
                    }
                }
            }
        }
예제 #10
0
        /// <summary>
        /// Asynchronously generates a <see cref="DatatypeDefinitionEnumeration"/> object from its XML representation.
        /// </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>
        internal override async Task ReadXmlAsync(XmlReader reader, CancellationToken token)
        {
            if (token.IsCancellationRequested)
            {
                token.ThrowIfCancellationRequested();
            }

            base.ReadXml(reader);

            using (var subtree = reader.ReadSubtree())
            {
                while (await subtree.ReadAsync())
                {
                    if (token.IsCancellationRequested)
                    {
                        token.ThrowIfCancellationRequested();
                    }

                    if (await subtree.MoveToContentAsync() == XmlNodeType.Element)
                    {
                        switch (subtree.LocalName)
                        {
                        case "ALTERNATIVE-ID":
                            var alternativeId = new AlternativeId(this);
                            alternativeId.ReadXml(reader);
                            break;

                        case "ENUM-VALUE":
                            var enumValue = new EnumValue(this, this.loggerFactory);
                            await enumValue.ReadXmlAsync(subtree, token);

                            break;
                        }
                    }
                }
            }
        }
예제 #11
0
        /// <summary>
        /// Asynchronously read the <see cref="AlternativeId"/> from the <see cref="XmlReader"/>
        /// </summary>
        /// <param name="reader">
        /// The reader to read from
        /// </param>
        /// <param name="token">
        /// A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        protected async Task ReadAlternativeIdAsync(XmlReader reader, CancellationToken token)
        {
            using (var subtree = reader.ReadSubtree())
            {
                while (await subtree.ReadAsync())
                {
                    if (token.IsCancellationRequested)
                    {
                        token.ThrowIfCancellationRequested();
                    }

                    if (await subtree.MoveToContentAsync() == XmlNodeType.Element)
                    {
                        switch (subtree.LocalName)
                        {
                        case "ALTERNATIVE-ID":
                            var alternativeId = new AlternativeId(this);
                            alternativeId.ReadXml(reader);
                            break;
                        }
                    }
                }
            }
        }
        /// <summary>
        /// Generates a <see cref="SpecElementWithAttributes"/> object from its XML representation.
        /// </summary>
        /// <param name="reader">
        /// an instance of <see cref="XmlReader"/>
        /// </param>
        public override void ReadXml(XmlReader reader)
        {
            base.ReadXml(reader);

            using (var specElementWithAttributesReader = reader.ReadSubtree())
            {
                while (specElementWithAttributesReader.Read())
                {
                    if (specElementWithAttributesReader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "ALTERNATIVE-ID")
                    {
                        var alternativeId = new AlternativeId(this);
                        alternativeId.ReadXml(specElementWithAttributesReader);
                    }

                    if (specElementWithAttributesReader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "TYPE")
                    {
                        using (var subtree = specElementWithAttributesReader.ReadSubtree())
                        {
                            subtree.MoveToContent();
                            this.ReadSpecType(subtree);
                        }
                    }

                    if (specElementWithAttributesReader.MoveToContent() == XmlNodeType.Element && reader.LocalName == "CHILDREN")
                    {
                        using (var subtree = specElementWithAttributesReader.ReadSubtree())
                        {
                            subtree.MoveToContent();
                            this.ReadHierarchy(subtree);
                        }
                    }

                    if (specElementWithAttributesReader.MoveToContent() == XmlNodeType.Element && specElementWithAttributesReader.LocalName == "ATTRIBUTE-VALUE-BOOLEAN")
                    {
                        using (var subtree = specElementWithAttributesReader.ReadSubtree())
                        {
                            subtree.MoveToContent();
                            var attributeValueBoolean = new AttributeValueBoolean(this);
                            attributeValueBoolean.ReadXml(subtree);
                        }
                    }

                    if (specElementWithAttributesReader.MoveToContent() == XmlNodeType.Element && specElementWithAttributesReader.LocalName == "ATTRIBUTE-VALUE-DATE")
                    {
                        using (var subtree = specElementWithAttributesReader.ReadSubtree())
                        {
                            subtree.MoveToContent();
                            var attributeValueDate = new AttributeValueDate(this);
                            attributeValueDate.ReadXml(subtree);
                        }
                    }

                    if (specElementWithAttributesReader.MoveToContent() == XmlNodeType.Element && specElementWithAttributesReader.LocalName == "ATTRIBUTE-VALUE-ENUMERATION")
                    {
                        using (var subtree = specElementWithAttributesReader.ReadSubtree())
                        {
                            subtree.MoveToContent();
                            var attributeValueEnumeration = new AttributeValueEnumeration(this);
                            attributeValueEnumeration.ReadXml(subtree);
                        }
                    }

                    if (specElementWithAttributesReader.MoveToContent() == XmlNodeType.Element && specElementWithAttributesReader.LocalName == "ATTRIBUTE-VALUE-INTEGER")
                    {
                        using (var subtree = specElementWithAttributesReader.ReadSubtree())
                        {
                            subtree.MoveToContent();
                            var attributeValueInteger = new AttributeValueInteger(this);
                            attributeValueInteger.ReadXml(subtree);
                        }
                    }

                    if (specElementWithAttributesReader.MoveToContent() == XmlNodeType.Element && specElementWithAttributesReader.LocalName == "ATTRIBUTE-VALUE-REAL")
                    {
                        using (var subtree = specElementWithAttributesReader.ReadSubtree())
                        {
                            subtree.MoveToContent();
                            var attributeValueReal = new AttributeValueReal(this);
                            attributeValueReal.ReadXml(subtree);
                        }
                    }

                    if (specElementWithAttributesReader.MoveToContent() == XmlNodeType.Element && specElementWithAttributesReader.LocalName == "ATTRIBUTE-VALUE-STRING")
                    {
                        using (var subtree = specElementWithAttributesReader.ReadSubtree())
                        {
                            subtree.MoveToContent();
                            var attributeValueString = new AttributeValueString(this);
                            attributeValueString.ReadXml(subtree);
                        }
                    }

                    if (specElementWithAttributesReader.MoveToContent() == XmlNodeType.Element && specElementWithAttributesReader.LocalName == "ATTRIBUTE-VALUE-XHTML")
                    {
                        using (var subtree = specElementWithAttributesReader.ReadSubtree())
                        {
                            subtree.MoveToContent();
                            var attributeValueXhtml = new AttributeValueXHTML(this);
                            attributeValueXhtml.ReadXml(subtree);
                        }
                    }

                    this.ReadObjectSpecificElements(specElementWithAttributesReader);
                }
            }
        }