/// <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; } } }
/// <summary> /// Sets the <see cref="DatatypeDefinitionDate"/> /// </summary> /// <param name="datatypeDefinition"> /// The instance of <see cref="DatatypeDefinitionDate"/> that is to be set. /// </param> protected override void SetDatatypeDefinition(DatatypeDefinition datatypeDefinition) { if (datatypeDefinition.GetType() != typeof(DatatypeDefinitionDate)) { throw new ArgumentException("datatypeDefinition must of type DatatypeDefinitionDate"); } this.Type = (DatatypeDefinitionDate)datatypeDefinition; }
/// <summary> /// Asynchronously generates a <see cref="AttributeDefinitionDate"/> 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) { base.ReadXml(reader); 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 "ATTRIBUTE-VALUE-DATE": this.DefaultValue = new AttributeValueDate(this, this.loggerFactory); using (var valueSubtree = reader.ReadSubtree()) { await valueSubtree.MoveToContentAsync(); await this.DefaultValue.ReadXmlAsync(valueSubtree, token); } break; case "DATATYPE-DEFINITION-DATE-REF": var reference = await reader.ReadElementContentAsStringAsync(); var datatypeDefinition = (DatatypeDefinitionDate)this.SpecType.ReqIFContent.DataTypes.SingleOrDefault(x => x.Identifier == reference); this.Type = datatypeDefinition; if (datatypeDefinition == null) { this.logger.LogTrace("The DatatypeDefinitionDate:{reference} could not be found and has been set to null on AttributeDefinitionDate:{Identifier}", reference, Identifier); } break; } } } }